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
19 #include <sys/types.h>
37 fprintf(stderr, "Usage: %s [-a|-A] [-s sid] [-t token] {pathname|handle}\n",
48 dm_sessid_t sid = DM_NO_SESSION;
49 dm_token_t token = DM_NO_TOKEN;
62 Progname = strrchr(argv[0], '/');
70 while ((opt = getopt(argc, argv, "Aas:t:v")) != EOF) {
91 if (optind + 1 != argc) {
94 pathname_obj = argv[optind];
96 if (dm_init_service(&name) == -1) {
97 fprintf(stderr, "Can't initialize the DMAPI\n");
100 if (sid == DM_NO_SESSION)
101 find_test_session(&sid);
103 /* Get the file's handle or convert the external handle. */
105 if (opaque_to_handle(pathname_obj, &hanp, &hlen)) {
106 fprintf(stderr, "can't get handle for %s\n", pathname_obj);
111 fprintf(stdout, "path/handle %s\n", pathname_obj);
113 /* Get the file's state, print it, then verify it against
114 what is in the file's stat block.
117 if (dm_get_fileattr(sid, hanp, hlen, token,
118 DM_AT_EMASK|DM_AT_PMANR|DM_AT_PATTR|DM_AT_DTIME|DM_AT_CFLAG|DM_AT_STAT,
120 fprintf(stderr, "dm_get_fileattr failed, %s\n",
125 print_state(&dmstat);
127 (void)validate_state(&dmstat, pathname_obj, 1);
130 if ((rc = filesys_bulkscan_init(pathname, &scanp)) != 0) {
131 fprintf(stderr, "filesys_bulkscan failed, %s\n",
132 fileio_err_image(rc));
136 rc = filesys_bulkscan_read(scanp, &fhandle, &fullstat);
137 if (rc != FILEIO_NOERROR)
140 (void)fhandle_to_buffer(&fhandle, buffer, sizeof(buffer));
142 fprintf(stdout, "handle %s\n", buffer);
143 print_state(&fullstat);
144 fprintf(stdout, "--------------------------\n");
146 fprintf(stdout, "%s|", buffer);
147 print_line(&fullstat);
151 if (rc != FILEIO_ENDOFSCAN) {
152 fprintf(stderr, "filesys_bulkscan_read failed, %s\n",
153 fileio_err_image(rc));
156 if ((rc = filesys_bulkscan_close(&scanp)) != 0) {
157 fprintf(stderr, "filesys_bulkscan_close failed, %s\n",
158 fileio_err_image(rc));