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
25 /*---------------------------------------------------------------------------
27 Test program used to test the DMAPI function dm_obj_ref_hold(). The
30 obj_ref_hold {-F} [-s sid] token {pathname|handle}
34 when a pathname is specified, -F indicates that its filesystem handle
35 should be used rather than its file object handle.
37 is the dm_sessid_t to use rather than the default test session.
39 is the dm_token_t to use.
41 is either a handle, or is the pathname of a file whose handle is
44 ----------------------------------------------------------------------------*/
47 extern char *sys_errlist[];
59 fprintf(stderr, "usage:\t%s [-F] [-s sid] token {pathname|handle}\n",
70 dm_sessid_t sid = DM_NO_SESSION;
79 Progname = strrchr(argv[0], '/');
86 /* Crack and validate the command line options. */
88 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
100 if (optind + 2 != argc)
102 token = atol(argv[optind++]);
103 object = argv[optind];
105 if (dm_init_service(&name) == -1) {
106 fprintf(stderr, "Can't initialize the DMAPI\n");
109 if (sid == DM_NO_SESSION)
110 find_test_session(&sid);
112 /* Get the file or filesystem's handle. */
114 if (opaque_to_handle(object, &hanp, &hlen)) {
115 fprintf(stderr, "can't get handle from %s\n", object);
122 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
123 fprintf(stderr, "can't get filesystem handle from %s\n",
127 dm_handle_free(hanp, hlen);
132 if (dm_obj_ref_hold(sid, token, hanp, hlen)) {
133 fprintf(stderr, "dm_obj_ref_hold failed, %s\n",
138 dm_handle_free(hanp, hlen);