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
24 /*---------------------------------------------------------------------------
26 Test program used to test the DMAPI function dm_get_eventlist(). The
29 get_eventlist [-F] [-n nelem] [-s sid] [-t token] {pathname|handle}
33 is the pathname of a file or filesystem or a handle.
35 is the value to use for the nelem parameter to dm_get_eventlist().
37 is the dm_sessid_t to use in place of the default test session.
39 is the dm_token_t to use in place of DM_NO_TOKEN.
41 is used when a pathname is specified to indicate that you want its
42 filesystem handle, not its file handle.
44 ----------------------------------------------------------------------------*/
57 fprintf(stderr, "usage:\t%s [-F] [-n nelem] [-s sid] [-t token] "
58 "{pathname|handle}\n",
69 dm_sessid_t sid = DM_NO_SESSION;
70 dm_token_t token = DM_NO_TOKEN;
71 u_int nelem = DM_EVENT_MAX;
73 dm_eventset_t eventset;
83 Progname = strrchr(argv[0], '/');
90 /* Crack and validate the command line options. */
92 while ((opt = getopt(argc, argv, "Fn:s:t:")) != EOF) {
104 token = atol(optarg);
110 if (optind + 1 != argc)
112 object = argv[optind];
114 if (dm_init_service(&name) == -1) {
115 fprintf(stderr, "Can't initialize the DMAPI\n");
119 if ((error = opaque_to_handle(object, &hanp, &hlen)) != 0) {
120 fprintf(stderr, "can't get a handle from %s, %s\n",
121 object, strerror(error));
129 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
130 fprintf(stderr, "can't get filesystem handle from %s\n",
134 dm_handle_free(hanp, hlen);
139 if (sid == DM_NO_SESSION)
140 find_test_session(&sid);
144 if (dm_get_eventlist(sid, hanp, hlen, token, nelem,
145 &eventset, &nelemp)) {
146 fprintf(stderr, "dm_get_eventlist failed, %s\n",
151 fprintf(stdout, "Events on object %s (0x%llx), nelemp %d:\n",
152 object, (unsigned long long) eventset, nelemp);
154 for (i = 0; i < nelemp; i++) {
155 if (!DMEV_ISSET(i, eventset))
158 case DM_EVENT_CANCEL:
159 fprintf(stdout, "DM_EVENT_CANCEL");
162 fprintf(stdout, "DM_EVENT_MOUNT");
164 case DM_EVENT_PREUNMOUNT:
165 fprintf(stdout, "DM_EVENT_PREUNMOUNT");
167 case DM_EVENT_UNMOUNT:
168 fprintf(stdout, "DM_EVENT_UNMOUNT");
171 fprintf(stdout, "DM_EVENT_DEBUT");
173 case DM_EVENT_CREATE:
174 fprintf(stdout, "DM_EVENT_CREATE");
177 fprintf(stdout, "DM_EVENT_CLOSE");
179 case DM_EVENT_POSTCREATE:
180 fprintf(stdout, "DM_EVENT_POSTCREATE");
182 case DM_EVENT_REMOVE:
183 fprintf(stdout, "DM_EVENT_REMOVE");
185 case DM_EVENT_POSTREMOVE:
186 fprintf(stdout, "DM_EVENT_POSTREMOVE");
188 case DM_EVENT_RENAME:
189 fprintf(stdout, "DM_EVENT_RENAME");
191 case DM_EVENT_POSTRENAME:
192 fprintf(stdout, "DM_EVENT_POSTRENAME");
195 fprintf(stdout, "DM_EVENT_LINK");
197 case DM_EVENT_POSTLINK:
198 fprintf(stdout, "DM_EVENT_POSTLINK");
200 case DM_EVENT_SYMLINK:
201 fprintf(stdout, "DM_EVENT_SYMLINK");
203 case DM_EVENT_POSTSYMLINK:
204 fprintf(stdout, "DM_EVENT_POSTSYMLINK");
207 fprintf(stdout, "DM_EVENT_READ");
210 fprintf(stdout, "DM_EVENT_WRITE");
212 case DM_EVENT_TRUNCATE:
213 fprintf(stdout, "DM_EVENT_TRUNCATE");
215 case DM_EVENT_ATTRIBUTE:
216 fprintf(stdout, "DM_EVENT_ATTRIBUTE");
218 case DM_EVENT_DESTROY:
219 fprintf(stdout, "DM_EVENT_DESTROY");
221 case DM_EVENT_NOSPACE:
222 fprintf(stdout, "DM_EVENT_NOSPACE");
225 fprintf(stdout, "DM_EVENT_USER");
228 fprintf(stdout, "DM_EVENT_23");
231 fprintf(stdout, " (%d)\n", i);
234 dm_handle_free(hanp, hlen);