_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size
[xfstests-dev.git] / dmapi / src / suite1 / cmd / path_to_handle.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
4  * All Rights Reserved.
5  */
6
7 /* Given a file object's pathname, print the object's handle. */
8
9 #include <lib/hsm.h>
10
11 #include <string.h>
12
13 /*---------------------------------------------------------------------------
14
15 Test program used to test dm_path_to_handle().  The command line is:
16
17         path_to_handle pathname
18
19 where pathname is the name of a file, directory, or symlink.
20
21 ----------------------------------------------------------------------------*/
22
23
24 char    *Progname;
25
26
27 static void
28 usage(void)
29 {
30         fprintf(stderr, "usage:\t%s pathname\n", Progname);
31         exit(1);
32 }
33
34
35 int
36 main(
37         int             argc,
38         char            **argv)
39 {
40         char            *pathname;
41         char            *name;
42         void            *hanp;
43         size_t          hlen;
44         char            buffer[100];
45
46         Progname = strrchr(argv[0], '/');
47         if (Progname) {
48                 Progname++;
49         } else {
50                 Progname = argv[0];
51         }
52
53         if (argc != 2)
54                 usage();
55         pathname = argv[1];
56
57         (void)dm_init_service(&name);
58
59         if (dm_path_to_handle(pathname, &hanp, &hlen) != 0) {
60                 fprintf(stderr, "dm_path_to_handle failed, %s\n",
61                         strerror(errno));
62                 return(1);
63         }
64         hantoa(hanp, hlen, buffer);
65         fprintf(stdout, "%s\n", buffer);
66
67         dm_handle_free(hanp, hlen);
68         return(0);
69 }