1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002 Silicon Graphics, Inc.
12 /*---------------------------------------------------------------------------
14 Test program used to test the DMAPI function dm_set_return_on_destroy(). The
17 set_return_on_destroy [-F] [-s sid] [-t token] {pathname|fshandle} [attr]
19 where pathname is the name of a file which resides in the filesystem of
20 interest. attr is the name of the DMAPI attribute; if none is specified,
21 then set-return-on-destroy will be disabled for the filesystem.
22 sid is the session ID whose attribute you are interested in setting.
24 Use -F if you want the program to find the fshandle based on the pathname.
26 ----------------------------------------------------------------------------*/
29 extern char *sys_errlist[];
40 fprintf(stderr, "usage:\t%s [-F] [-s sid] [-t token] {pathname|fshandle} [attr]\n", Progname);
50 dm_sessid_t sid = DM_NO_SESSION;
51 dm_token_t token = DM_NO_TOKEN;
53 dm_attrname_t *attrnamep = NULL;
54 dm_boolean_t enable = DM_FALSE;
61 Progname = strrchr(argv[0], '/');
68 /* Crack and validate the command line options. */
70 while ((opt = getopt(argc, argv, "Fs:t:")) != EOF) {
85 if (optind == argc || optind + 2 < argc)
87 pathname = argv[optind++];
90 attrnamep = (dm_attrname_t *)argv[optind++];
93 if (dm_init_service(&name) == -1) {
94 fprintf(stderr, "Can't initialize the DMAPI\n");
97 if (sid == DM_NO_SESSION)
98 find_test_session(&sid);
100 if (opaque_to_handle(pathname, &hanp, &hlen)) {
101 fprintf(stderr, "can't get handle for %s\n", pathname);
105 /* Get the file's handle. */
111 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
112 fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
113 pathname, strerror(errno));
116 dm_handle_free(hanp, hlen);
121 if (dm_set_return_on_destroy(sid, hanp, hlen, token,
122 attrnamep, enable)) {
123 fprintf(stderr, "dm_set_return_on_destroy failed, %s\n",
128 dm_handle_free(hanp, hlen);