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_release_right(). The
30 release_right {-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 if (Progname = strrchr(argv[0], '/')) {
85 /* Crack and validate the command line options. */
87 while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
99 if (optind + 2 != argc)
101 token = atol(argv[optind++]);
102 object = argv[optind];
104 if (dm_init_service(&name) == -1) {
105 fprintf(stderr, "Can't initialize the DMAPI\n");
108 if (sid == DM_NO_SESSION)
109 find_test_session(&sid);
111 /* Get the file or filesystem's handle. */
113 if (opaque_to_handle(object, &hanp, &hlen)) {
114 fprintf(stderr, "can't get handle from %s\n", object);
121 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
122 fprintf(stderr, "can't get filesystem handle from %s\n",
126 dm_handle_free(hanp, hlen);
131 if (dm_release_right(sid, hanp, hlen, token)) {
132 fprintf(stderr, "dm_release_right failed, %s\n",
137 dm_handle_free(hanp, hlen);