/*
- * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
- *
+ * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
+ *
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
- *
+ *
* This program is distributed in the hope that it would be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
+ *
* Further, this software is distributed without any warranty that it is
* free of the rightful claim of any third person regarding infringement
* or the like. Any license provided herein, whether implied or
* otherwise, applies only to this software file. Patent licenses, if
* any, provided herein do not apply to combinations of this program with
* other software, or any other product whatsoever.
- *
+ *
* You should have received a copy of the GNU General Public License along
* with this program; if not, write the Free Software Foundation, Inc., 59
* Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
+ *
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
* Mountain View, CA 94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
+ *
+ * http://www.sgi.com
+ *
+ * For further information regarding this notice, see:
+ *
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
*/
#include <libxfs.h>
#include <math.h>
-#include <getopt.h>
#include <sys/time.h>
#include "bmap.h"
#include "check.h"
#include "command.h"
-#include "data.h"
#include "io.h"
#include "output.h"
#include "type.h"
-#include "mount.h"
+#include "init.h"
#include "malloc.h"
typedef enum {
freetab_t **freetabp);
static xfs_dir2_data_free_t
*process_data_dir_v2_freefind(xfs_dir2_data_t *data,
- xfs_dir2_data_unused_t *dup);
+ xfs_dir2_data_unused_t *dup);
static void process_dir(xfs_dinode_t *dip, blkmap_t *blkmap,
inodata_t *id);
static int process_dir_v1(xfs_dinode_t *dip, blkmap_t *blkmap,
static void setlink_inode(inodata_t *id, nlink_t nlink, int isdir,
int security);
-static const cmdinfo_t blockfree_cmd =
+static const cmdinfo_t blockfree_cmd =
{ "blockfree", NULL, blockfree_f, 0, 0, 0,
NULL, "free block usage information", NULL };
-static const cmdinfo_t blockget_cmd =
+static const cmdinfo_t blockget_cmd =
{ "blockget", "check", blockget_f, 0, -1, 0,
"[-s|-v] [-n] [-b bno]... [-i ino] ...",
"get block usage and check consistency", NULL };
#ifdef DEBUG
-static const cmdinfo_t blocktrash_cmd =
+static const cmdinfo_t blocktrash_cmd =
{ "blocktrash", NULL, blocktrash_f, 0, -1, 0,
"[-n count] [-x minlen] [-y maxlen] [-s seed] [-0123] [-t type] ...",
"trash randomly selected block(s)", NULL };
#endif
-static const cmdinfo_t blockuse_cmd =
+static const cmdinfo_t blockuse_cmd =
{ "blockuse", NULL, blockuse_f, 0, 3, 0,
"[-n] [-c blockcount]",
"print usage for current block(s)", NULL };
-static const cmdinfo_t ncheck_cmd =
+static const cmdinfo_t ncheck_cmd =
{ "ncheck", NULL, ncheck_f, 0, -1, 0,
"[-s] [-i ino] ...",
"print inode-name pairs", NULL };
id->name[namelen] = '\0';
}
-static void
+static void
addparent_inode(
inodata_t *id,
xfs_ino_t parent)
for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
/*
* Check that there are no blocks either
- * a) unaccounted for or
+ * a) unaccounted for or
* b) bno-free but not cnt-free
*/
checknot_dbmap(agno, 0, mp->m_sb.sb_agblocks,
ep = ep->next;
}
}
-
+
}
static int
while ((c = getopt(argc, argv, "b:i:npsv")) != EOF) {
switch (c) {
case 'b':
- bno = atoll(optarg);
+ bno = strtoll(optarg, NULL, 10);
add_blist(bno);
break;
case 'i':
- ino = atoll(optarg);
+ ino = strtoll(optarg, NULL, 10);
add_ilist(ino);
break;
case 'n':
while ((c = getopt(argc, argv, "i:s")) != EOF) {
switch (c) {
case 'i':
- ino = atoll(optarg);
+ ino = strtoll(optarg, NULL, 10);
ilist = xrealloc(ilist, (ilist_size + 1) *
sizeof(*ilist));
ilist[ilist_size++] = ino;
len = (int)(strlen(oldpath) + strlen(parent) + 2);
path = xmalloc(len);
- sprintf(path, "%s/%s", parent, oldpath);
+ snprintf(path, len, "%s/%s", parent, oldpath);
return path;
}
if (!sflag || id->ilist)
dbprintf("numrecs for ino %lld %s fork bmap root too "
"large (%u)\n",
- id->ino,
+ id->ino,
whichfork == XFS_DATA_FORK ? "data" : "attr",
INT_GET(dib->bb_numrecs, ARCH_CONVERT));
error++;
"dev", "local", "extents", "btree", "uuid"
};
- /* convert the core, then copy it back into the inode */
+ /* convert the core, then copy it back into the inode */
libxfs_xlate_dinode_core((xfs_caddr_t)&dip->di_core, &tdic, 1,
ARCH_CONVERT);
memcpy(&dip->di_core, &tdic, sizeof(xfs_dinode_core_t));
dbprintf("inode %lld mode %#o fmt %s "
"afmt %s "
"nex %d anex %d nblk %lld sz %lld%s%s\n",
- id->ino, dic->di_mode, fmtnames[dic->di_format],
- fmtnames[dic->di_aformat],
+ id->ino, dic->di_mode, fmtnames[(int)dic->di_format],
+ fmtnames[(int)dic->di_aformat],
dic->di_nextents,
dic->di_anextents,
dic->di_nblocks, dic->di_size,
ic = 1;
break;
default:
+ break;
}
if (ic)
quota_add(dic->di_gid, dic->di_uid, 0, bc, ic, rc);
entry = &leaf->entries[0];
for (i = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); entry++, i++) {
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT));
- lino=DIRINO_GET_ARCH(&namest->inumber, ARCH_CONVERT);
+ lino=DIRINO_GET_ARCH(&namest->inumber, ARCH_CONVERT);
cid = find_inode(lino, 1);
if (v)
dbprintf("dir %lld entry %*.*s %lld\n", id->ino,
}
break;
case XFS_DIR2_LEAFN_MAGIC:
- /* if it's at the root location then we can check the
+ /* if it's at the root location then we can check the
* pointers are null XXX */
break;
case XFS_DA_NODE_MAGIC:
if ((dqb = iocur_top->data) == NULL) {
pop_cur();
if (scicb)
- dbprintf("can't read block %lld for %s quota "
+ dbprintf("can't read block %lld for %s quota "
"inode (fsblock %lld)\n",
(xfs_dfiloff_t)qbno, s,
(xfs_dfsbno_t)bno);
INT_GET(dqb->dd_diskdq.d_rtbcount, ARCH_CONVERT));
if (INT_GET(dqb->dd_diskdq.d_magic, ARCH_CONVERT) != XFS_DQUOT_MAGIC) {
if (scicb)
- dbprintf("bad magic number %#x for %s "
+ dbprintf("bad magic number %#x for %s "
"dqblk %lld entry %d id %d\n",
INT_GET(dqb->dd_diskdq.d_magic, ARCH_CONVERT), s,
(xfs_dfiloff_t)qbno, i, dqid);
(*dot)++;
sfe = &sf->list[0];
for (i = INT_GET(sf->hdr.count, ARCH_CONVERT) - 1; i >= 0; i--) {
- lino = DIRINO_GET_ARCH(&sfe->inumber, ARCH_CONVERT);
+ lino = DIRINO_GET_ARCH(&sfe->inumber, ARCH_CONVERT);
cid = find_inode(lino, 1);
if (cid == NULL) {
if (!sflag)
dbprintf("dir %llu size is %lld, should be %d\n",
id->ino, dip->di_core.di_size,
(int)((char *)sfe - (char *)sf));
- lino=DIRINO_GET_ARCH(&sf->hdr.parent, ARCH_CONVERT);
+ lino=DIRINO_GET_ARCH(&sf->hdr.parent, ARCH_CONVERT);
cid = find_inode(lino, 1);
if (cid)
addlink_inode(cid);
agffreeblks = agflongest = 0;
agicount = agifreecount = 0;
push_cur();
- set_cur(&typtab[TYP_SB], XFS_AG_DADDR(mp, agno, XFS_SB_DADDR), 1,
- DB_RING_IGN, NULL);
-
+ set_cur(&typtab[TYP_SB],
+ XFS_AG_DADDR(mp, agno, XFS_SB_DADDR),
+ XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL);
+
if (!iocur_top->data) {
dbprintf("can't read superblock for ag %u\n", agno);
pop_cur();
serious_error++;
return;
}
-
+
libxfs_xlate_sb(iocur_top->data, sb, 1, ARCH_CONVERT, XFS_SB_ALL_BITS);
-
+
if (sb->sb_magicnum != XFS_SB_MAGIC) {
if (!sflag)
dbprintf("bad sb magic # %#x in ag %u\n",
set_dbmap(agno, XFS_FSB_TO_AGBNO(mp, sb->sb_logstart),
sb->sb_logblocks, DBM_LOG, agno, XFS_SB_BLOCK(mp));
push_cur();
- set_cur(&typtab[TYP_AGF], XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR), 1,
- DB_RING_IGN, NULL);
+ set_cur(&typtab[TYP_AGF],
+ XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
+ XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL);
if ((agf = iocur_top->data) == NULL) {
dbprintf("can't read agf block for ag %u\n", agno);
pop_cur();
sb->sb_agblocks - INT_GET(agf->agf_length, ARCH_CONVERT),
DBM_MISSING, agno, XFS_SB_BLOCK(mp));
push_cur();
- set_cur(&typtab[TYP_AGI], XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR), 1,
- DB_RING_IGN, NULL);
+ set_cur(&typtab[TYP_AGI],
+ XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
+ XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL);
if ((agi = iocur_top->data) == NULL) {
dbprintf("can't read agi block for ag %u\n", agno);
serious_error++;
for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) {
if (INT_GET(agi->agi_unlinked[i], ARCH_CONVERT) != NULLAGINO) {
if (!sflag) {
- xfs_agino_t agino=INT_GET(agi->agi_unlinked[i], ARCH_CONVERT);
+ xfs_agino_t agino=INT_GET(agi->agi_unlinked[i], ARCH_CONVERT);
dbprintf("agi unlinked bucket %d is %u in ag "
"%u (inode=%lld)\n", i, agino, agno,
- XFS_AGINO_TO_INO(mp, agno, agino));
- }
+ XFS_AGINO_TO_INO(mp, agno, agino));
+ }
error++;
}
}
return;
push_cur();
set_cur(&typtab[TYP_AGFL],
- XFS_AG_DADDR(mp, seqno, XFS_AGFL_DADDR), 1, DB_RING_IGN, NULL);
+ XFS_AG_DADDR(mp, seqno, XFS_AGFL_DADDR(mp)),
+ XFS_FSS_TO_BB(mp, 1), DB_RING_IGN, NULL);
if ((agfl = iocur_top->data) == NULL) {
dbprintf("can't read agfl block for ag %u\n", seqno);
serious_error++;
count++;
if (i == INT_GET(agf->agf_fllast, ARCH_CONVERT))
break;
- if (++i == XFS_AGFL_SIZE)
+ if (++i == XFS_AGFL_SIZE(mp))
i = 0;
}
if (count != INT_GET(agf->agf_flcount, ARCH_CONVERT)) {