2 * Copyright (c) 2000-2002 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
24 /*---------------------------------------------------------------------------
26 Test program used to test the DMAPI function dm_set_return_on_destroy(). The
29 set_return_on_destroy [-F] [-s sid] [-t token] {pathname|fshandle} [attr]
31 where pathname is the name of a file which resides in the filesystem of
32 interest. attr is the name of the DMAPI attribute; if none is specified,
33 then set-return-on-destroy will be disabled for the filesystem.
34 sid is the session ID whose attribute you are interested in setting.
36 Use -F if you want the program to find the fshandle based on the pathname.
38 ----------------------------------------------------------------------------*/
41 extern char *sys_errlist[];
52 fprintf(stderr, "usage:\t%s [-F] [-s sid] [-t token] {pathname|fshandle} [attr]\n", Progname);
62 dm_sessid_t sid = DM_NO_SESSION;
63 dm_token_t token = DM_NO_TOKEN;
65 dm_attrname_t *attrnamep = NULL;
66 dm_boolean_t enable = DM_FALSE;
73 if (Progname = strrchr(argv[0], '/')) {
79 /* Crack and validate the command line options. */
81 while ((opt = getopt(argc, argv, "Fs:t:")) != EOF) {
96 if (optind == argc || optind + 2 < argc)
98 pathname = argv[optind++];
101 attrnamep = (dm_attrname_t *)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 if (opaque_to_handle(pathname, &hanp, &hlen)) {
112 fprintf(stderr, "can't get handle for %s\n", pathname);
116 /* Get the file's handle. */
122 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
123 fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
124 pathname, strerror(errno));
127 dm_handle_free(hanp, hlen);
132 if (dm_set_return_on_destroy(sid, hanp, hlen, token,
133 attrnamep, enable)) {
134 fprintf(stderr, "dm_set_return_on_destroy failed, %s\n",
139 dm_handle_free(hanp, hlen);