kernel - Fix auto port assignment collision in network code
[dragonfly.git] / sbin / hammer2 / print_inode.c
blob701286a2000b4e6e56879c89670a52fa936bcefc
1 /*
2 * Copyright (c) 2013-2019 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@dragonflybsd.org>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
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.
35 #include "hammer2.h"
37 static void
38 hexdump_inode(const void *data, size_t len)
40 const unsigned char *p = data;
41 size_t i;
43 if (VerboseOpt <= 0)
44 return;
46 for (i = 0; i < len; i++) {
47 printf("%02X", *p);
48 if (i && !((i + 1) % 16))
49 printf("\n");
50 else if (i != len - 1)
51 printf(" ");
52 p++;
54 printf("\n");
57 void
58 print_inode(const char *path)
60 hammer2_ioc_inode_t inode;
61 hammer2_inode_data_t *ipdata;
62 hammer2_inode_meta_t *meta;
63 char *str = NULL;
64 int fd;
65 uuid_t uuid;
67 fd = hammer2_ioctl_handle(path);
68 if (fd == -1)
69 return;
71 if (ioctl(fd, HAMMER2IOC_INODE_GET, &inode) == -1) {
72 printf("ioctl(HAMMER2IOC_INODE_GET) failed\n");
73 return;
75 ipdata = &inode.ip_data;
76 meta = &ipdata->meta;
78 hexdump_inode(meta, sizeof(*meta));
80 printf("version = %u\n", meta->version);
81 printf("pfs_subtype = %u (%s)\n", meta->pfs_subtype,
82 hammer2_pfssubtype_to_str(meta->pfs_subtype));
83 printf("uflags = 0x%x\n", (unsigned int)meta->uflags);
84 printf("rmajor = %u\n", meta->rmajor);
85 printf("rminor = %u\n", meta->rminor);
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));
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));
94 printf("type = %u (%s)\n", meta->type,
95 hammer2_iptype_to_str(meta->type));
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);
99 printf("inum = 0x%jx\n", (uintmax_t)meta->inum);
100 printf("size = %ju\n", (uintmax_t)meta->size);
101 printf("nlinks = %ju\n", (uintmax_t)meta->nlinks);
102 printf("iparent = 0x%jx\n", (uintmax_t)meta->iparent);
103 printf("name_key = 0x%jx\n", (uintmax_t)meta->name_key);
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);
107 printf("check_algo = %u\n", meta->check_algo);
108 printf("pfs_nmasters = %u\n", meta->pfs_nmasters);
109 printf("pfs_type = %u (%s)\n", meta->pfs_type,
110 hammer2_pfstype_to_str(meta->pfs_type));
111 printf("pfs_inum = 0x%jx\n", (uintmax_t)meta->pfs_inum);
112 uuid = meta->pfs_clid;
113 printf("pfs_clid = %s\n", hammer2_uuid_to_str(&uuid, &str));
114 uuid = meta->pfs_fsid;
115 printf("pfs_fsid = %s\n", hammer2_uuid_to_str(&uuid, &str));
116 printf("data_quota = 0x%jx\n", (uintmax_t)meta->data_quota);
117 printf("inode_quota = 0x%jx\n", (uintmax_t)meta->inode_quota);
118 printf("pfs_lsnap_tid = 0x%jx\n", (uintmax_t)meta->pfs_lsnap_tid);
119 printf("decrypt_check = 0x%jx\n", (uintmax_t)meta->decrypt_check);
121 free(str);