]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_db: add support for CRC format remote symlinks
authorDave Chinner <dchinner@redhat.com>
Fri, 7 Jun 2013 00:26:07 +0000 (10:26 +1000)
committerBen Myers <bpm@sgi.com>
Tue, 6 Aug 2013 21:07:59 +0000 (16:07 -0500)
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
db/Makefile
db/field.c
db/field.h
db/symlink.c [new file with mode: 0644]
db/symlink.h [new file with mode: 0644]
db/type.c

index d331964f3cc28a59d3809ca4703e6ab7685d9d69..9485b8249f72b61ee5c6e2bf9b2dedde5992ff13 100644 (file)
@@ -12,7 +12,7 @@ HFILES = addr.h agf.h agfl.h agi.h attr.h attrshort.h bit.h block.h bmap.h \
        dir2.h dir2sf.h dquot.h echo.h faddr.h field.h \
        flist.h fprint.h frag.h freesp.h hash.h help.h init.h inode.h input.h \
        io.h malloc.h metadump.h output.h print.h quit.h sb.h sig.h strvec.h \
-       text.h type.h write.h attrset.h
+       text.h type.h write.h attrset.h symlink.h
 CFILES = $(HFILES:.h=.c)
 LSRCFILES = xfs_admin.sh xfs_check.sh xfs_ncheck.sh xfs_metadump.sh
 
index 26332f1510d411dfbbd22704b9b31d1e79e7ff1d..e4f6c7da254ad0962bf180ad41a2957d124d70d4 100644 (file)
@@ -34,6 +34,7 @@
 #include "dquot.h"
 #include "dir2.h"
 #include "dir2sf.h"
+#include "symlink.h"
 
 const ftattr_t ftattrtab[] = {
        { FLDT_AEXTNUM, "aextnum", fp_num, "%d", SI(bitsz(xfs_aextnum_t)),
@@ -300,6 +301,11 @@ const ftattr_t     ftattrtab[] = {
          NULL, NULL },
        { FLDT_SB, "sb", NULL, (char *)sb_flds, sb_size, FTARG_SIZE, NULL,
          sb_flds },
+
+/* CRC enabled symlink */
+       { FLDT_SYMLINK_CRC, "symlink", NULL, (char *)symlink_crc_flds,
+         symlink_size, FTARG_SIZE, NULL, symlink_crc_flds },
+
        { FLDT_TIME, "time", fp_time, NULL, SI(bitsz(__int32_t)), FTARG_SIGNED,
          NULL, NULL },
        { FLDT_TIMESTAMP, "timestamp", NULL, (char *)timestamp_flds,
index 9a12f1c4225ec83e4634367eec8cead901e3429a..b97d917907019021391af2b099a1bf46cc7c2f91 100644 (file)
@@ -150,6 +150,10 @@ typedef enum fldt  {
        FLDT_QCNT,
        FLDT_QWARNCNT,
        FLDT_SB,
+
+       /* CRC enabled symlink */
+       FLDT_SYMLINK_CRC,
+
        FLDT_TIME,
        FLDT_TIMESTAMP,
        FLDT_UINT1,
diff --git a/db/symlink.c b/db/symlink.c
new file mode 100644 (file)
index 0000000..9f3d0b9
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013 Red Hat, 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.  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 <xfs/libxfs.h>
+#include "type.h"
+#include "faddr.h"
+#include "fprint.h"
+#include "field.h"
+#include "bit.h"
+#include "init.h"
+
+
+/*
+ * XXX: no idea how to handle multiple contiguous block symlinks here.
+ */
+static int
+symlink_count(
+       void            *obj,
+       int             startoff)
+{
+       struct xfs_dsymlink_hdr *hdr = obj;
+
+       ASSERT(startoff == 0);
+
+       if (hdr->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
+               return 0;
+       if (be32_to_cpu(hdr->sl_bytes) + sizeof(*hdr) > mp->m_sb.sb_blocksize)
+               return mp->m_sb.sb_blocksize - sizeof(*hdr);
+       return be32_to_cpu(hdr->sl_bytes);
+}
+
+int
+symlink_size(
+       void    *obj,
+       int     startoff,
+       int     idx)
+{
+       struct xfs_dsymlink_hdr *hdr = obj;
+
+       ASSERT(startoff == 0);
+       if (hdr->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
+               return 0;
+       return be32_to_cpu(hdr->sl_bytes) + sizeof(*hdr);
+}
+
+const struct field     symlink_crc_hfld[] = {
+       { "", FLDT_SYMLINK_CRC, OI(0), C1, 0, TYP_NONE },
+       { NULL }
+};
+
+#define        OFF(f)  bitize(offsetof(struct xfs_dsymlink_hdr, sl_ ## f))
+#define        SZOF(f) bitize(sizeof(struct xfs_dsymlink_hdr))
+const struct field     symlink_crc_flds[] = {
+       { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
+       { "offset", FLDT_UINT32D, OI(OFF(offset)), C1, 0, TYP_NONE },
+       { "bytes", FLDT_UINT32D, OI(OFF(bytes)), C1, 0, TYP_NONE },
+       { "crc", FLDT_UINT32X, OI(OFF(crc)), C1, 0, TYP_NONE },
+       { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
+       { "owner", FLDT_INO, OI(OFF(owner)), C1, 0, TYP_NONE },
+       { "bno", FLDT_DFSBNO, OI(OFF(blkno)), C1, 0, TYP_BMAPBTD },
+       { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
+       { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_dsymlink_hdr))),
+               symlink_count, FLD_COUNT, TYP_NONE },
+       { NULL }
+};
+
diff --git a/db/symlink.h b/db/symlink.h
new file mode 100644 (file)
index 0000000..86ca842
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2013 Red Hat, 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.  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
+ */
+#ifndef __XFS_DB_SYMLINK_H
+#define __XFS_DB_SYMLINK_H
+
+extern const struct field      symlink_crc_hfld[];
+extern const struct field      symlink_crc_flds[];
+
+extern int     symlink_size(void *obj, int startoff, int idx);
+
+#endif /* __XFS_DB_SYMLINK_H */
index 80a584b1cff2a10b8f3a3bfa23156b28e7e861fd..64e2ef4e2835d41cb1d245cfe1f0fa10d947c4f4 100644 (file)
--- a/db/type.c
+++ b/db/type.c
@@ -38,6 +38,7 @@
 #include "dquot.h"
 #include "dir2.h"
 #include "text.h"
+#include "symlink.h"
 
 static const typ_t     *findtyp(char *name);
 static int             type_f(int argc, char **argv);
@@ -91,7 +92,7 @@ static const typ_t    __typtab_crc[] = {
        { TYP_RTBITMAP, "rtbitmap", NULL, NULL },
        { TYP_RTSUMMARY, "rtsummary", NULL, NULL },
        { TYP_SB, "sb", handle_struct, sb_hfld },
-       { TYP_SYMLINK, "symlink", handle_string, NULL },
+       { TYP_SYMLINK, "symlink", handle_struct, symlink_crc_hfld },
        { TYP_TEXT, "text", handle_text, NULL },
        { TYP_NONE, NULL }
 };