]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blame - db/symlink.c
xfsprogs: Remove trailing blanks on various places
[thirdparty/xfsprogs-dev.git] / db / symlink.c
CommitLineData
3cafd875
DC
1/*
2 * Copyright (c) 2013 Red Hat, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
6b803e5a 19#include "libxfs.h"
3cafd875
DC
20#include "type.h"
21#include "faddr.h"
22#include "fprint.h"
23#include "field.h"
24#include "bit.h"
25#include "init.h"
26
27
28/*
29 * XXX: no idea how to handle multiple contiguous block symlinks here.
30 */
31static int
32symlink_count(
33 void *obj,
34 int startoff)
35{
36 struct xfs_dsymlink_hdr *hdr = obj;
37
38 ASSERT(startoff == 0);
39
40 if (hdr->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
41 return 0;
42 if (be32_to_cpu(hdr->sl_bytes) + sizeof(*hdr) > mp->m_sb.sb_blocksize)
43 return mp->m_sb.sb_blocksize - sizeof(*hdr);
44 return be32_to_cpu(hdr->sl_bytes);
45}
46
47int
48symlink_size(
49 void *obj,
50 int startoff,
51 int idx)
52{
53 struct xfs_dsymlink_hdr *hdr = obj;
54
55 ASSERT(startoff == 0);
56 if (hdr->sl_magic != cpu_to_be32(XFS_SYMLINK_MAGIC))
57 return 0;
58 return be32_to_cpu(hdr->sl_bytes) + sizeof(*hdr);
59}
60
61const struct field symlink_crc_hfld[] = {
62 { "", FLDT_SYMLINK_CRC, OI(0), C1, 0, TYP_NONE },
63 { NULL }
64};
65
66#define OFF(f) bitize(offsetof(struct xfs_dsymlink_hdr, sl_ ## f))
67#define SZOF(f) bitize(sizeof(struct xfs_dsymlink_hdr))
68const struct field symlink_crc_flds[] = {
69 { "magic", FLDT_UINT32X, OI(OFF(magic)), C1, 0, TYP_NONE },
70 { "offset", FLDT_UINT32D, OI(OFF(offset)), C1, 0, TYP_NONE },
71 { "bytes", FLDT_UINT32D, OI(OFF(bytes)), C1, 0, TYP_NONE },
0522f1cc 72 { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE },
3cafd875
DC
73 { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE },
74 { "owner", FLDT_INO, OI(OFF(owner)), C1, 0, TYP_NONE },
75 { "bno", FLDT_DFSBNO, OI(OFF(blkno)), C1, 0, TYP_BMAPBTD },
76 { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE },
77 { "data", FLDT_CHARNS, OI(bitize(sizeof(struct xfs_dsymlink_hdr))),
78 symlink_count, FLD_COUNT, TYP_NONE },
79 { NULL }
80};