]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - db/frag.c
apply gettext translation to more strings
[thirdparty/xfsprogs-dev.git] / db / frag.c
index af0b13890551107f0aeafa674206c690639938b0..925863d6db173c0e30d3b651e16799ef3449fa9c 100644 (file)
--- a/db/frag.c
+++ b/db/frag.c
@@ -1,36 +1,22 @@
 /*
- * 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
+ * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms 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/
+ *
+ * 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.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#include <libxfs.h>
+#include <xfs/libxfs.h>
 #include <sys/time.h>
 #include "bmap.h"
 #include "command.h"
@@ -65,12 +51,12 @@ static int          Rflag;
 static int             rflag;
 static int             vflag;
 
-typedef void   (*scan_lbtree_f_t)(xfs_btree_lblock_t   *block,
+typedef void   (*scan_lbtree_f_t)(struct xfs_btree_block *block,
                                   int                  level,
                                   extmap_t             **extmapp,
                                   typnm_t              btype);
 
-typedef void   (*scan_sbtree_f_t)(xfs_btree_sblock_t   *block,
+typedef void   (*scan_sbtree_f_t)(struct xfs_btree_block *block,
                                   int                  level,
                                   xfs_agf_t            *agf);
 
@@ -96,14 +82,14 @@ static void         scan_lbtree(xfs_fsblock_t root, int nlevels,
 static void            scan_sbtree(xfs_agf_t *agf, xfs_agblock_t root,
                                    int nlevels, scan_sbtree_f_t func,
                                    typnm_t btype);
-static void            scanfunc_bmap(xfs_btree_lblock_t *ablock, int level,
+static void            scanfunc_bmap(struct xfs_btree_block *block, int level,
                                      extmap_t **extmapp, typnm_t btype);
-static void            scanfunc_ino(xfs_btree_sblock_t *ablock, int level,
+static void            scanfunc_ino(struct xfs_btree_block *block, int level,
                                     xfs_agf_t *agf);
 
-static const cmdinfo_t frag_cmd = 
+static const cmdinfo_t frag_cmd =
        { "frag", NULL, frag_f, 0, -1, 0,
-         "[-a] [-d] [-f] [-l] [-r]",
+         "[-a] [-d] [-f] [-l] [-q] [-R] [-r] [-v]",
          "get file fragmentation data", NULL };
 
 static extmap_t *
@@ -184,7 +170,7 @@ frag_f(
                         (double)extcount_actual;
        else
                answer = 0.0;
-       dbprintf("actual %llu, ideal %llu, fragmentation factor %.2f%%\n",
+       dbprintf(_("actual %llu, ideal %llu, fragmentation factor %.2f%%\n"),
                extcount_actual, extcount_ideal, answer);
        return 0;
 }
@@ -225,7 +211,7 @@ init(
                        vflag = 1;
                        break;
                default:
-                       dbprintf("bad option for frag command\n");
+                       dbprintf(_("bad option for frag command\n"));
                        return 0;
                }
        }
@@ -265,23 +251,16 @@ process_btinode(
        xfs_bmbt_rec_32_t       *rp;
 
        dib = (xfs_bmdr_block_t *)XFS_DFORK_PTR(dip, whichfork);
-       if (INT_GET(dib->bb_level, ARCH_CONVERT) == 0) {
-               rp = (xfs_bmbt_rec_32_t *)XFS_BTREE_REC_ADDR(
-                       XFS_DFORK_SIZE(dip, mp, whichfork),
-                       xfs_bmdr, dib, 1,
-                       XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_SIZE(dip, mp,
-                                       whichfork),
-                               xfs_bmdr, 1));
-               process_bmbt_reclist(rp, INT_GET(dib->bb_numrecs, ARCH_CONVERT), extmapp);
+       if (be16_to_cpu(dib->bb_level) == 0) {
+               rp = (xfs_bmbt_rec_32_t *)XFS_BMDR_REC_ADDR(dib, 1);
+               process_bmbt_reclist(rp, be16_to_cpu(dib->bb_numrecs), extmapp);
                return;
        }
-       pp = XFS_BTREE_PTR_ADDR(XFS_DFORK_SIZE(dip, mp, whichfork),
-               xfs_bmdr, dib, 1,
-               XFS_BTREE_BLOCK_MAXRECS(XFS_DFORK_SIZE(dip, mp, whichfork),
-                                       xfs_bmdr, 0));
-       for (i = 0; i < INT_GET(dib->bb_numrecs, ARCH_CONVERT); i++)
-               scan_lbtree((xfs_fsblock_t)INT_GET(pp[i], ARCH_CONVERT), INT_GET(dib->bb_level, ARCH_CONVERT), scanfunc_bmap,
-                       extmapp,
+       pp = XFS_BMDR_PTR_ADDR(dib, 1,
+               xfs_bmdr_maxrecs(mp, XFS_DFORK_SIZE(dip, mp, whichfork), 0));
+       for (i = 0; i < be16_to_cpu(dib->bb_numrecs); i++)
+               scan_lbtree(be64_to_cpu(pp[i]), be16_to_cpu(dib->bb_level), 
+                       scanfunc_bmap, extmapp,
                        whichfork == XFS_DATA_FORK ? TYP_BMAPBTD : TYP_BMAPBTA);
 }
 
@@ -336,13 +315,13 @@ process_inode(
        int                     skipd;
 
        dic = &dip->di_core;
-       ino = XFS_AGINO_TO_INO(mp, INT_GET(agf->agf_seqno, ARCH_CONVERT), agino);
-       switch (dic->di_mode & IFMT) {
-       case IFDIR:
+       ino = XFS_AGINO_TO_INO(mp, be32_to_cpu(agf->agf_seqno), agino);
+       switch (be16_to_cpu(dic->di_mode) & S_IFMT) {
+       case S_IFDIR:
                skipd = !dflag;
                break;
-       case IFREG:
-               if (!rflag && (dic->di_flags & XFS_DIFLAG_REALTIME))
+       case S_IFREG:
+               if (!rflag && (be16_to_cpu(dic->di_flags) & XFS_DIFLAG_REALTIME))
                        skipd = 1;
                else if (!Rflag &&
                         (ino == mp->m_sb.sb_rbmino ||
@@ -355,7 +334,7 @@ process_inode(
                else
                        skipd = !fflag;
                break;
-       case IFLNK:
+       case S_IFLNK:
                skipd = !lflag;
                break;
        default:
@@ -370,7 +349,7 @@ process_inode(
        if (!skipa)
                process_fork(dip, XFS_ATTR_FORK);
        if (vflag && (!skipd || !skipa))
-               dbprintf("inode %lld actual %lld ideal %lld\n",
+               dbprintf(_("inode %lld actual %lld ideal %lld\n"),
                        ino, extcount_actual - actual, extcount_ideal - ideal);
 }
 
@@ -386,7 +365,7 @@ scan_ag(
                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);
+               dbprintf(_("can't read agf block for ag %u\n"), agno);
                pop_cur();
                return;
        }
@@ -395,15 +374,13 @@ scan_ag(
                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);
+               dbprintf(_("can't read agi block for ag %u\n"), agno);
                pop_cur();
                pop_cur();
                return;
        }
-       scan_sbtree(agf,
-               INT_GET(agi->agi_root, ARCH_CONVERT),
-               INT_GET(agi->agi_level, ARCH_CONVERT),
-               scanfunc_ino, TYP_INOBT);
+       scan_sbtree(agf, be32_to_cpu(agi->agi_root), 
+                       be32_to_cpu(agi->agi_level), scanfunc_ino, TYP_INOBT);
        pop_cur();
        pop_cur();
 }
@@ -420,7 +397,7 @@ scan_lbtree(
        set_cur(&typtab[btype], XFS_FSB_TO_DADDR(mp, root), blkbb, DB_RING_IGN,
                NULL);
        if (iocur_top->data == NULL) {
-               dbprintf("can't read btree block %u/%u\n",
+               dbprintf(_("can't read btree block %u/%u\n"),
                        XFS_FSB_TO_AGNO(mp, root),
                        XFS_FSB_TO_AGBNO(mp, root));
                return;
@@ -437,13 +414,13 @@ scan_sbtree(
        scan_sbtree_f_t func,
        typnm_t         btype)
 {
-       xfs_agnumber_t  seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT);
+       xfs_agnumber_t  seqno = be32_to_cpu(agf->agf_seqno);
 
        push_cur();
        set_cur(&typtab[btype], XFS_AGB_TO_DADDR(mp, seqno, root),
                blkbb, DB_RING_IGN, NULL);
        if (iocur_top->data == NULL) {
-               dbprintf("can't read btree block %u/%u\n", seqno, root);
+               dbprintf(_("can't read btree block %u/%u\n"), seqno, root);
                return;
        }
        (*func)(iocur_top->data, nlevels - 1, agf);
@@ -452,38 +429,35 @@ scan_sbtree(
 
 static void
 scanfunc_bmap(
-       xfs_btree_lblock_t      *ablock,
+       struct xfs_btree_block  *block,
        int                     level,
        extmap_t                **extmapp,
        typnm_t                 btype)
 {
-       xfs_bmbt_block_t        *block = (xfs_bmbt_block_t *)ablock;
        int                     i;
        xfs_bmbt_ptr_t          *pp;
-       xfs_bmbt_rec_32_t       *rp;
+       xfs_bmbt_rec_t          *rp;
 
        if (level == 0) {
-               rp = (xfs_bmbt_rec_32_t *)
-                       XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt,
-                       block, 1, mp->m_bmap_dmxr[0]);
-               process_bmbt_reclist(rp, INT_GET(block->bb_numrecs, ARCH_CONVERT), extmapp);
+               rp = XFS_BMBT_REC_ADDR(mp, block, 1);
+               process_bmbt_reclist((xfs_bmbt_rec_32_t *)rp, 
+                               be16_to_cpu(block->bb_numrecs), extmapp);
                return;
        }
-       pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_bmbt, block, 1,
-               mp->m_bmap_dmxr[0]);
-       for (i = 0; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++)
-               scan_lbtree(INT_GET(pp[i], ARCH_CONVERT), level, scanfunc_bmap, extmapp, btype);
+       pp = XFS_BMBT_PTR_ADDR(mp, block, 1, mp->m_bmap_dmxr[0]);
+       for (i = 0; i < be16_to_cpu(block->bb_numrecs); i++)
+               scan_lbtree(be64_to_cpu(pp[i]), level, scanfunc_bmap, extmapp, 
+                                                                       btype);
 }
 
 static void
 scanfunc_ino(
-       xfs_btree_sblock_t      *ablock,
+       struct xfs_btree_block  *block,
        int                     level,
        xfs_agf_t               *agf)
 {
        xfs_agino_t             agino;
-       xfs_inobt_block_t       *block = (xfs_inobt_block_t *)ablock;
-       xfs_agnumber_t          seqno = INT_GET(agf->agf_seqno, ARCH_CONVERT);
+       xfs_agnumber_t          seqno = be32_to_cpu(agf->agf_seqno);
        int                     i;
        int                     j;
        int                     off;
@@ -491,10 +465,9 @@ scanfunc_ino(
        xfs_inobt_rec_t         *rp;
 
        if (level == 0) {
-               rp = XFS_BTREE_REC_ADDR(mp->m_sb.sb_blocksize, xfs_inobt, block,
-                       1, mp->m_inobt_mxr[0]);
-               for (i = 0; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++) {
-                       agino = INT_GET(rp[i].ir_startino, ARCH_CONVERT);
+               rp = XFS_INOBT_REC_ADDR(mp, block, 1);
+               for (i = 0; i < be16_to_cpu(block->bb_numrecs); i++) {
+                       agino = be32_to_cpu(rp[i].ir_startino);
                        off = XFS_INO_TO_OFFSET(mp, agino);
                        push_cur();
                        set_cur(&typtab[TYP_INODE],
@@ -503,32 +476,23 @@ scanfunc_ino(
                                XFS_FSB_TO_BB(mp, XFS_IALLOC_BLOCKS(mp)),
                                DB_RING_IGN, NULL);
                        if (iocur_top->data == NULL) {
-                               dbprintf("can't read inode block %u/%u\n",
+                               dbprintf(_("can't read inode block %u/%u\n"),
                                        seqno, XFS_AGINO_TO_AGBNO(mp, agino));
                                continue;
                        }
                        for (j = 0; j < XFS_INODES_PER_CHUNK; j++) {
-                                xfs_dinode_t            *dip;
-                                xfs_dinode_core_t       tdic;
-                                
-                                dip=(xfs_dinode_t *)((char *)iocur_top->data + ((off + j) << mp->m_sb.sb_inodelog));
-                            
-                                /* 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));
-        
-                               if (XFS_INOBT_IS_FREE(&rp[i], j, ARCH_CONVERT))
+                               if (XFS_INOBT_IS_FREE_DISK(&rp[i], j))
                                        continue;
-                               process_inode(agf, agino + j,
-                                       (xfs_dinode_t *)((char *)iocur_top->data + ((off + j) << mp->m_sb.sb_inodelog)));
+                               process_inode(agf, agino + j, (xfs_dinode_t *)
+                                       ((char *)iocur_top->data + 
+                                       ((off + j) << mp->m_sb.sb_inodelog)));
                        }
                        pop_cur();
                }
                return;
        }
-       pp = XFS_BTREE_PTR_ADDR(mp->m_sb.sb_blocksize, xfs_inobt, block, 1,
-               mp->m_inobt_mxr[1]);
-       for (i = 0; i < INT_GET(block->bb_numrecs, ARCH_CONVERT); i++)
-               scan_sbtree(agf, INT_GET(pp[i], ARCH_CONVERT), level, scanfunc_ino, TYP_INOBT);
+       pp = XFS_INOBT_PTR_ADDR(mp, block, 1, mp->m_inobt_mxr[1]);
+       for (i = 0; i < be16_to_cpu(block->bb_numrecs); i++)
+               scan_sbtree(agf, be32_to_cpu(pp[i]), level, scanfunc_ino, 
+                                                               TYP_INOBT);
 }