4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2014, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/utils/ll_decode_filter_fid.c
34 * Tool for printing the OST filter_fid structure on the objects
35 * in human readable form.
37 * Author: Andreas Dilger <adilger@sun.com>
43 #include <sys/types.h>
44 #include <sys/xattr.h>
45 #include <asm/byteorder.h>
46 #include <lustre/lustre_user.h>
48 int main(int argc, char *argv[])
53 for (i = 1; i < argc; i++) {
54 char buf[1024]; /* allow xattr that may be larger */
55 struct filter_fid *ff = (void *)buf;
58 size = getxattr(argv[i], "trusted.fid", buf,
59 sizeof(struct filter_fid_old));
61 fprintf(stderr, "%s: error reading fid: %s\n",
62 argv[i], strerror(errno));
67 if (size > sizeof(struct filter_fid_old)) {
68 fprintf(stderr, "%s: warning: fid larger than expected"
69 " (%d bytes), recompile?\n", argv[i], size);
70 } else if (size > sizeof(*ff)) {
71 struct filter_fid_old *ffo = (void *)buf;
74 printf("%s: objid=%llu seq=%llu parent="DFID
75 " stripe=%u\n", argv[i],
76 (unsigned long long)__le64_to_cpu(ffo->ff_objid),
77 (unsigned long long)__le64_to_cpu(ffo->ff_seq),
78 (unsigned long long)__le64_to_cpu(ffo->ff_parent.f_seq),
79 le32toh(ffo->ff_parent.f_oid), 0 /* ver */,
80 /* this is stripe_nr actually */
81 le32toh(ffo->ff_parent.f_stripe_idx));
83 printf("%s: parent="DFID" stripe=%u\n", argv[i],
84 (unsigned long long)__le64_to_cpu(ff->ff_parent.f_seq),
85 __le32_to_cpu(ff->ff_parent.f_oid), 0, /* ver */
86 /* this is stripe_nr actually */
87 __le32_to_cpu(ff->ff_parent.f_stripe_idx));