4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or https://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2019 by Delphix. All rights reserved.
26 #include <sys/types.h>
33 libzfs_handle_t
*g_zfs
;
38 fprintf(stderr
, "Usage: zfs_ids_to_path [-v] <pool> <objset id> "
44 main(int argc
, char **argv
)
46 boolean_t verbose
= B_FALSE
;
48 while ((c
= getopt(argc
, argv
, "v")) != -1) {
59 (void) fprintf(stderr
, "Incorrect number of arguments: %d\n",
64 uint64_t objset
, object
;
65 if (sscanf(argv
[1], "%llu", (u_longlong_t
*)&objset
) != 1) {
66 (void) fprintf(stderr
, "Invalid objset id: %s\n", argv
[1]);
69 if (sscanf(argv
[2], "%llu", (u_longlong_t
*)&object
) != 1) {
70 (void) fprintf(stderr
, "Invalid object id: %s\n", argv
[2]);
73 if ((g_zfs
= libzfs_init()) == NULL
) {
74 (void) fprintf(stderr
, "%s\n", libzfs_error_init(errno
));
77 zpool_handle_t
*pool
= zpool_open(g_zfs
, argv
[0]);
79 fprintf(stderr
, "Could not open pool %s\n", argv
[0]);
84 char pathname
[PATH_MAX
* 2];
86 zpool_obj_to_path_ds(pool
, objset
, object
, pathname
,
89 zpool_obj_to_path(pool
, objset
, object
, pathname
,
92 printf("%s\n", pathname
);