2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
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.
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.
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
19 #include <sys/types.h>
20 #include <sys/param.h>
27 /*---------------------------------------------------------------------------
29 Test program used to test the DMAPI function dm_get_mountinfo(). The
32 get_mountinfo [-b buflen] [-s sid] pathname
34 where pathname is the name of a file, buflen is the size of the buffer to use
35 in the call, and sid is the session ID whose attributes you are interested in.
37 ----------------------------------------------------------------------------*/
40 * Define some standard formats for the printf statements below.
43 #define HDR "%s: token %d sequence %d\n"
44 #define VALS "\t%-15s %s\n"
45 #define VALD "\t%-15s %d\n"
47 #define VALLLD "\t%-15s %lld\n"
49 #define VALLLD "\t%-15s %ld\n"
53 extern char *sys_errlist[];
66 fprintf(stderr, "usage:\t%s [-b buflen] [-s sid] pathname\n",
77 dm_sessid_t sid = DM_NO_SESSION;
80 size_t buflen = 10000;
87 if (Progname = strrchr(argv[0], '/')) {
93 /* Crack and validate the command line options. */
95 while ((opt = getopt(argc, argv, "b:s:")) != EOF) {
98 buflen = atol(optarg);
107 if (optind + 1 != argc)
109 pathname = argv[optind++];
111 if (dm_init_service(&name) == -1) {
112 fprintf(stderr, "Can't initialize the DMAPI\n");
115 if (sid == DM_NO_SESSION)
116 find_test_session(&sid);
118 /* Get the file's handle. */
120 if (dm_path_to_fshandle(pathname, &fshanp, &fshlen)) {
121 fprintf(stderr, "can't get fshandle for file %s, %s\n",
122 pathname, strerror(errno));
127 if ((bufp = malloc(buflen)) == NULL) {
128 fprintf(stderr, "malloc failed, %s\n", strerror(errno));
133 if (dm_get_mountinfo(sid, fshanp, fshlen, DM_NO_TOKEN, buflen,
135 if (errno == E2BIG) {
136 fprintf(stderr, "dm_get_mountinfo buffer too small, "
137 "should be %d bytes\n", rlenp);
139 fprintf(stderr, "dm_get_mountinfo failed, %s\n",
144 fprintf(stdout, "rlenp is %d\n", rlenp);
145 print_one_mount_event(bufp);
147 dm_handle_free(fshanp, fshlen);