+// SPDX-License-Identifier: GPL-2.0
/*
- * Copyright (c) 2000-2001 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://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
*/
-#include <xfs/libxfs.h>
+#include "libxfs.h"
#include "block.h"
#include "bmap.h"
#include "command.h"
static void print_rawdata(void *data, int len);
static const cmdinfo_t ablock_cmd =
- { "ablock", NULL, ablock_f, 1, 1, 1, "filoff",
- "set address to file offset (attr fork)", ablock_help };
+ { "ablock", NULL, ablock_f, 1, 1, 1, N_("filoff"),
+ N_("set address to file offset (attr fork)"), ablock_help };
static const cmdinfo_t daddr_cmd =
- { "daddr", NULL, daddr_f, 0, 1, 1, "[d]",
- "set address to daddr value", daddr_help };
+ { "daddr", NULL, daddr_f, 0, 1, 1, N_("[d]"),
+ N_("set address to daddr value"), daddr_help };
static const cmdinfo_t dblock_cmd =
- { "dblock", NULL, dblock_f, 1, 1, 1, "filoff",
- "set address to file offset (data fork)", dblock_help };
+ { "dblock", NULL, dblock_f, 1, 1, 1, N_("filoff"),
+ N_("set address to file offset (data fork)"), dblock_help };
static const cmdinfo_t fsblock_cmd =
- { "fsblock", "fsb", fsblock_f, 0, 1, 1, "[fsb]",
- "set address to fsblock value", fsblock_help };
+ { "fsblock", "fsb", fsblock_f, 0, 1, 1, N_("[fsb]"),
+ N_("set address to fsblock value"), fsblock_help };
static void
ablock_help(void)
{
- dbprintf(
+ dbprintf(_(
"\n Example:\n"
"\n"
" 'ablock 23' - sets the file position to the 23rd filesystem block in\n"
" the inode's attribute fork. The filesystem block size is specified in\n"
" the superblock.\n\n"
-);
+));
}
/*ARGSUSED*/
static int
ablock_f(
- int argc,
- char **argv)
+ int argc,
+ char **argv)
{
- bmap_ext_t bm;
- xfs_dfiloff_t bno;
- xfs_dfsbno_t dfsbno;
- int haveattr;
- int nex;
- char *p;
+ bmap_ext_t bm;
+ xfs_fileoff_t bno;
+ xfs_fsblock_t dfsbno;
+ int haveattr;
+ xfs_extnum_t nex;
+ char *p;
+ struct xfs_dinode *dip = iocur_top->data;
- bno = (xfs_dfiloff_t)strtoull(argv[1], &p, 0);
+ bno = (xfs_fileoff_t)strtoull(argv[1], &p, 0);
if (*p != '\0') {
- dbprintf("bad block number %s\n", argv[1]);
+ dbprintf(_("bad block number %s\n"), argv[1]);
return 0;
}
push_cur();
set_cur_inode(iocur_top->ino);
- haveattr = XFS_DFORK_Q((xfs_dinode_t *)iocur_top->data);
+ if (!dip) {
+ pop_cur();
+ dbprintf(_("no current inode\n"));
+ return 0;
+ }
+ haveattr = dip->di_forkoff;
pop_cur();
if (!haveattr) {
- dbprintf("no attribute data for file\n");
+ dbprintf(_("no attribute data for file\n"));
return 0;
}
nex = 1;
bmap(bno, 1, XFS_ATTR_FORK, &nex, &bm);
if (nex == 0) {
- dbprintf("file attr block is unmapped\n");
+ dbprintf(_("file attr block is unmapped\n"));
return 0;
}
dfsbno = bm.startblock + (bno - bm.startoff);
ASSERT(typtab[TYP_ATTR].typnm == TYP_ATTR);
- set_cur(&typtab[TYP_ATTR], (__int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
+ set_cur(&typtab[TYP_ATTR], (int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
blkbb, DB_RING_ADD, NULL);
return 0;
}
static void
daddr_help(void)
{
- dbprintf(
+ dbprintf(_(
"\n Example:\n"
"\n"
" 'daddr 102' - sets position to the 102nd absolute disk block\n"
" (512 byte block).\n"
-);
+));
}
static int
int argc,
char **argv)
{
- __int64_t d;
+ int64_t d;
char *p;
+ int bb_count = BTOBB(mp->m_sb.sb_sectsize);
if (argc == 1) {
- dbprintf("current daddr is %lld\n", iocur_top->off >> BBSHIFT);
+ xfs_daddr_t daddr = iocur_top->off >> BBSHIFT;
+
+ if (iocur_is_ddev(iocur_top))
+ dbprintf(_("datadev daddr is %lld\n"), daddr);
+ else if (iocur_is_extlogdev(iocur_top))
+ dbprintf(_("logdev daddr is %lld\n"), daddr);
+ else
+ dbprintf(_("current daddr is %lld\n"), daddr);
+
return 0;
}
- d = (__int64_t)strtoull(argv[1], &p, 0);
+ d = (int64_t)strtoull(argv[1], &p, 0);
if (*p != '\0' ||
d >= mp->m_sb.sb_dblocks << (mp->m_sb.sb_blocklog - BBSHIFT)) {
- dbprintf("bad daddr %s\n", argv[1]);
+ dbprintf(_("bad daddr %s\n"), argv[1]);
return 0;
}
ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);
- set_cur(&typtab[TYP_DATA], d, 1, DB_RING_ADD, NULL);
+ set_cur(&typtab[TYP_DATA], d, bb_count, DB_RING_ADD, NULL);
return 0;
}
static void
dblock_help(void)
{
- dbprintf(
+ dbprintf(_(
"\n Example:\n"
"\n"
" 'dblock 23' - sets the file position to the 23rd filesystem block in\n"
" the inode's data fork. The filesystem block size is specified in the\n"
" superblock.\n\n"
-);
+));
}
static int
{
bbmap_t bbmap;
bmap_ext_t *bmp;
- xfs_dfiloff_t bno;
- xfs_dfsbno_t dfsbno;
+ xfs_fileoff_t bno;
+ xfs_fsblock_t dfsbno;
int nb;
- int nex;
+ xfs_extnum_t nex;
char *p;
typnm_t type;
- bno = (xfs_dfiloff_t)strtoull(argv[1], &p, 0);
+ bno = (xfs_fileoff_t)strtoull(argv[1], &p, 0);
if (*p != '\0') {
- dbprintf("bad block number %s\n", argv[1]);
+ dbprintf(_("bad block number %s\n"), argv[1]);
return 0;
}
push_cur();
type = inode_next_type();
pop_cur();
if (type == TYP_NONE) {
- dbprintf("no type for file data\n");
+ dbprintf(_("no type for file data\n"));
return 0;
}
- nex = nb = type == TYP_DIR2 ? mp->m_dirblkfsbs : 1;
+ nex = nb = type == TYP_DIR2 ? mp->m_dir_geo->fsbcount : 1;
bmp = malloc(nb * sizeof(*bmp));
bmap(bno, nb, XFS_DATA_FORK, &nex, bmp);
if (nex == 0) {
- dbprintf("file data block is unmapped\n");
+ dbprintf(_("file data block is unmapped\n"));
free(bmp);
return 0;
}
ASSERT(typtab[type].typnm == type);
if (nex > 1)
make_bbmap(&bbmap, nex, bmp);
- set_cur(&typtab[type], (__int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
+ set_cur(&typtab[type], (int64_t)XFS_FSB_TO_DADDR(mp, dfsbno),
nb * blkbb, DB_RING_ADD, nex > 1 ? &bbmap : NULL);
free(bmp);
return 0;
static void
fsblock_help(void)
{
- dbprintf(
+ dbprintf(_(
"\n Example:\n"
"\n"
" 'fsblock 1023' - sets the file position to the 1023rd filesystem block.\n"
" The filesystem block size is specified in the superblock and set during\n"
" mkfs time. Offset is absolute (not AG relative).\n\n"
-);
+));
}
static int
{
xfs_agblock_t agbno;
xfs_agnumber_t agno;
- xfs_dfsbno_t d;
+ xfs_fsblock_t d;
char *p;
if (argc == 1) {
- dbprintf("current fsblock is %lld\n",
+ if (!iocur_is_ddev(iocur_top)) {
+ dbprintf(_("cursor does not point to data device\n"));
+ return 0;
+ }
+ dbprintf(_("current fsblock is %lld\n"),
XFS_DADDR_TO_FSB(mp, iocur_top->off >> BBSHIFT));
return 0;
}
d = strtoull(argv[1], &p, 0);
if (*p != '\0') {
- dbprintf("bad fsblock %s\n", argv[1]);
+ dbprintf(_("bad fsblock %s\n"), argv[1]);
return 0;
}
agno = XFS_FSB_TO_AGNO(mp, d);
agbno = XFS_FSB_TO_AGBNO(mp, d);
if (agno >= mp->m_sb.sb_agcount || agbno >= mp->m_sb.sb_agblocks) {
- dbprintf("bad fsblock %s\n", argv[1]);
+ dbprintf(_("bad fsblock %s\n"), argv[1]);
return 0;
}
ASSERT(typtab[TYP_DATA].typnm == TYP_DATA);