xfstests: eliminate warnings under dmapi/src/suite1/cmd (3)
[xfstests-dev.git] / dmapi / src / suite1 / cmd / path_to_fshandle.c
1 /*
2  * Copyright (c) 2000-2001 Silicon Graphics, Inc.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it would be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write the Free Software Foundation,
16  * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  */
18
19 /* Given a file object's pathname, print the filesystem handle. */
20
21 #include <lib/hsm.h>
22
23 #include <string.h>
24
25 /*---------------------------------------------------------------------------
26
27 Test program used to test dm_path_to_fshandle().  The command line is:
28
29         path_to_fshandle pathname
30
31 where pathname is the name of a file, directory, or symlink.
32
33 ----------------------------------------------------------------------------*/
34
35
36 char    *Progname;
37
38
39 static void
40 usage(void)
41 {
42         fprintf(stderr, "usage:\t%s pathname\n", Progname);
43         exit(1);
44 }
45
46
47 int
48 main(
49         int             argc,
50         char            **argv)
51 {
52         char            *pathname;
53         char            *name;
54         void            *fshanp;
55         size_t          fshlen;
56         char            buffer[100];
57
58         Progname = strrchr(argv[0], '/');
59         if (Progname) {
60                 Progname++;
61         } else {
62                 Progname = argv[0];
63         }
64
65         if (argc != 2)
66                 usage();
67         pathname = argv[1];
68
69         (void)dm_init_service(&name);
70
71         if (dm_path_to_fshandle(pathname, &fshanp, &fshlen) != 0) {
72                 fprintf(stderr, "dm_path_to_fshandle failed, %s\n",
73                         strerror(errno));
74                 return(1);
75         }
76         hantoa(fshanp, fshlen, buffer);
77         fprintf(stdout, "%s\n", buffer);
78
79         dm_handle_free(fshanp, fshlen);
80         return(0);
81 }