]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - db/agfl.c
libxfs: sanitize agcount on load
[thirdparty/xfsprogs-dev.git] / db / agfl.c
index 4bc9c5894fbc3af524afdd91442bc73106cf920d..472873e0ab37b5fce37c639058732d5fa69475ee 100644 (file)
--- a/db/agfl.c
+++ b/db/agfl.c
@@ -1,37 +1,22 @@
 /*
- * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2001,2005 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
+ * 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.
+ * 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.
  *
- * 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/
+ * 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 <xfs/libxfs.h>
-#include "agfl.h"
+#include "libxfs.h"
 #include "command.h"
 #include "type.h"
 #include "faddr.h"
 #include "bit.h"
 #include "output.h"
 #include "init.h"
+#include "agfl.h"
 
 static int agfl_bno_size(void *obj, int startoff);
 static int agfl_f(int argc, char **argv);
 static void agfl_help(void);
 
 static const cmdinfo_t agfl_cmd =
-       { "agfl", NULL, agfl_f, 0, 1, 1, "[agno]",
-         "set address to agfl block", agfl_help };
+       { "agfl", NULL, agfl_f, 0, 1, 1, N_("[agno]"),
+         N_("set address to agfl block"), agfl_help };
 
 const field_t  agfl_hfld[] = { {
        "", FLDT_AGFL, OI(0), C1, 0, TYP_NONE, },
        { NULL }
 };
 
+const field_t  agfl_crc_hfld[] = { {
+       "", FLDT_AGFL_CRC, OI(0), C1, 0, TYP_NONE, },
+       { NULL }
+};
+
 #define        OFF(f)  bitize(offsetof(xfs_agfl_t, agfl_ ## f))
 const field_t  agfl_flds[] = {
+       { "bno", FLDT_AGBLOCKNZ, OI(OFF(magicnum)), agfl_bno_size,
+         FLD_ARRAY|FLD_COUNT, TYP_DATA },
+       { NULL }
+};
+
+const field_t  agfl_crc_flds[] = {
+       { "magicnum", FLDT_UINT32X, OI(OFF(magicnum)), C1, 0, TYP_NONE },
+       { "seqno", FLDT_AGNUMBER, OI(OFF(seqno)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+       { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
        { "bno", FLDT_AGBLOCKNZ, OI(OFF(bno)), agfl_bno_size,
          FLD_ARRAY|FLD_COUNT, TYP_DATA },
        { NULL }
@@ -73,7 +75,7 @@ agfl_bno_size(
 static void
 agfl_help(void)
 {
-       dbprintf(
+       dbprintf(_(
 "\n"
 " set allocation group freelist\n"
 "\n"
@@ -86,7 +88,7 @@ agfl_help(void)
 " for each allocation group.  This acts as a reserved pool of space\n"
 " separate from the general filesystem freespace (not used for user data).\n"
 "\n"
-);
+));
 
 }
 
@@ -101,7 +103,7 @@ agfl_f(
        if (argc > 1) {
                agno = (xfs_agnumber_t)strtoul(argv[1], &p, 0);
                if (*p != '\0' || agno >= mp->m_sb.sb_agcount) {
-                       dbprintf("bad allocation group number %s\n", argv[1]);
+                       dbprintf(_("bad allocation group number %s\n"), argv[1]);
                        return 0;
                }
                cur_agno = agno;