Commit | Line | Data |
---|---|---|
355d67fc | 1 | /* |
4685ca1c | 2 | * Copyright (c) 2013-2019 The DragonFly Project. All rights reserved. |
355d67fc | 3 | * |
8adee7de MD |
4 | * This code is derived from software contributed to The DragonFly Project |
5 | * by Matthew Dillon <dillon@dragonflybsd.org> | |
355d67fc MD |
6 | * |
7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | |
10 | * | |
11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in | |
15 | * the documentation and/or other materials provided with the | |
16 | * distribution. | |
17 | * 3. Neither the name of The DragonFly Project nor the names of its | |
18 | * contributors may be used to endorse or promote products derived | |
19 | * from this software without specific, prior written permission. | |
20 | * | |
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
22 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
23 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
24 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
25 | * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
27 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
28 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
29 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
30 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
31 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | |
33 | */ | |
34 | ||
35 | #include "hammer2.h" | |
36 | ||
4685ca1c TK |
37 | static void |
38 | hexdump_inode(const void *data, size_t len) | |
355d67fc | 39 | { |
4685ca1c TK |
40 | const unsigned char *p = data; |
41 | size_t i; | |
42 | ||
43 | if (VerboseOpt <= 0) | |
44 | return; | |
45 | ||
46 | for (i = 0; i < len; i++) { | |
47 | printf("%02X", *p); | |
e005fd43 TK |
48 | if (i && !((i + 1) % 16)) |
49 | printf("\n"); | |
50 | else if (i != len - 1) | |
4685ca1c TK |
51 | printf(" "); |
52 | p++; | |
53 | } | |
54 | printf("\n"); | |
55 | } | |
56 | ||
57 | void | |
58 | print_inode(const char *path) | |
59 | { | |
60 | hammer2_ioc_inode_t inode; | |
61 | hammer2_inode_data_t *ipdata; | |
62 | hammer2_inode_meta_t *meta; | |
d4a14304 | 63 | char *str = NULL; |
0716ab18 | 64 | int fd; |
bc092eef | 65 | uuid_t uuid; |
4685ca1c TK |
66 | |
67 | fd = hammer2_ioctl_handle(path); | |
68 | if (fd == -1) | |
69 | return; | |
70 | ||
71 | if (ioctl(fd, HAMMER2IOC_INODE_GET, &inode) == -1) { | |
72 | printf("ioctl(HAMMER2IOC_INODE_GET) failed\n"); | |
73 | return; | |
74 | } | |
75 | ipdata = &inode.ip_data; | |
76 | meta = &ipdata->meta; | |
77 | ||
78 | hexdump_inode(meta, sizeof(*meta)); | |
e005fd43 | 79 | |
4685ca1c | 80 | printf("version = %u\n", meta->version); |
e005fd43 TK |
81 | printf("pfs_subtype = %u (%s)\n", meta->pfs_subtype, |
82 | hammer2_pfssubtype_to_str(meta->pfs_subtype)); | |
4685ca1c TK |
83 | printf("uflags = 0x%x\n", (unsigned int)meta->uflags); |
84 | printf("rmajor = %u\n", meta->rmajor); | |
85 | printf("rminor = %u\n", meta->rminor); | |
9b3bda23 TK |
86 | printf("ctime = %s\n", hammer2_time64_to_str(meta->ctime, &str)); |
87 | printf("mtime = %s\n", hammer2_time64_to_str(meta->mtime, &str)); | |
88 | printf("atime = %s\n", hammer2_time64_to_str(meta->atime, &str)); | |
89 | printf("btime = %s\n", hammer2_time64_to_str(meta->btime, &str)); | |
bc092eef TK |
90 | uuid = meta->uid; |
91 | printf("uid = %s\n", hammer2_uuid_to_str(&uuid, &str)); | |
92 | uuid = meta->gid; | |
93 | printf("gid = %s\n", hammer2_uuid_to_str(&uuid, &str)); | |
e005fd43 TK |
94 | printf("type = %u (%s)\n", meta->type, |
95 | hammer2_iptype_to_str(meta->type)); | |
4685ca1c TK |
96 | printf("op_flags = 0x%x\n", meta->op_flags); |
97 | printf("cap_flags = 0x%x\n", meta->cap_flags); | |
98 | printf("mode = 0%o\n", meta->mode); | |
378b013c | 99 | printf("inum = 0x%jx\n", (uintmax_t)meta->inum); |
4685ca1c TK |
100 | printf("size = %ju\n", (uintmax_t)meta->size); |
101 | printf("nlinks = %ju\n", (uintmax_t)meta->nlinks); | |
2ce7e786 | 102 | printf("iparent = 0x%jx\n", (uintmax_t)meta->iparent); |
378b013c | 103 | printf("name_key = 0x%jx\n", (uintmax_t)meta->name_key); |
4685ca1c TK |
104 | printf("name_len = %u\n", meta->name_len); |
105 | printf("ncopies = %u\n", meta->ncopies); | |
106 | printf("comp_algo = %u\n", meta->comp_algo); | |
378b013c TK |
107 | printf("target_type = %u\n", meta->target_type); |
108 | printf("check_algo = %u\n", meta->check_algo); | |
109 | printf("pfs_nmasters = %u\n", meta->pfs_nmasters); | |
e005fd43 TK |
110 | printf("pfs_type = %u (%s)\n", meta->pfs_type, |
111 | hammer2_pfstype_to_str(meta->pfs_type)); | |
378b013c | 112 | printf("pfs_inum = 0x%jx\n", (uintmax_t)meta->pfs_inum); |
bc092eef TK |
113 | uuid = meta->pfs_clid; |
114 | printf("pfs_clid = %s\n", hammer2_uuid_to_str(&uuid, &str)); | |
115 | uuid = meta->pfs_fsid; | |
116 | printf("pfs_fsid = %s\n", hammer2_uuid_to_str(&uuid, &str)); | |
378b013c TK |
117 | printf("data_quota = 0x%jx\n", (uintmax_t)meta->data_quota); |
118 | printf("inode_quota = 0x%jx\n", (uintmax_t)meta->inode_quota); | |
119 | printf("pfs_lsnap_tid = 0x%jx\n", (uintmax_t)meta->pfs_lsnap_tid); | |
120 | printf("decrypt_check = 0x%jx\n", (uintmax_t)meta->decrypt_check); | |
9b3bda23 TK |
121 | |
122 | free(str); | |
355d67fc | 123 | } |