2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
39 /*---------------------------------------------------------------------------
41 Test program used to test the DMAPI function dm_get_eventlist(). The
44 get_eventlist [-F] [-n nelem] [-s sid] [-t token] {pathname|handle}
48 is the pathname of a file or filesystem or a handle.
50 is the value to use for the nelem parameter to dm_get_eventlist().
52 is the dm_sessid_t to use in place of the default test session.
54 is the dm_token_t to use in place of DM_NO_TOKEN.
56 is used when a pathname is specified to indicate that you want its
57 filesystem handle, not its file handle.
59 ----------------------------------------------------------------------------*/
72 fprintf(stderr, "usage:\t%s [-F] [-n nelem] [-s sid] [-t token] "
73 "{pathname|handle}\n",
84 dm_sessid_t sid = DM_NO_SESSION;
85 dm_token_t token = DM_NO_TOKEN;
86 u_int nelem = DM_EVENT_MAX;
88 dm_eventset_t eventset;
98 if (Progname = strrchr(argv[0], '/')) {
104 /* Crack and validate the command line options. */
106 while ((opt = getopt(argc, argv, "Fn:s:t:")) != EOF) {
112 nelem = atol(optarg);
118 token = atol(optarg);
124 if (optind + 1 != argc)
126 object = argv[optind];
128 if (dm_init_service(&name) == -1) {
129 fprintf(stderr, "Can't inititalize the DMAPI\n");
133 if ((error = opaque_to_handle(object, &hanp, &hlen)) != 0) {
134 fprintf(stderr, "can't get a handle from %s, %s\n",
135 object, strerror(error));
143 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
144 fprintf(stderr, "can't get filesystem handle from %s\n",
148 dm_handle_free(hanp, hlen);
153 if (sid == DM_NO_SESSION)
154 find_test_session(&sid);
158 if (dm_get_eventlist(sid, hanp, hlen, token, nelem,
159 &eventset, &nelemp)) {
160 fprintf(stderr, "dm_get_eventlist failed, %s\n",
166 fprintf(stdout, "Events on object %s (0x%x), nelemp %d:\n",
168 fprintf(stdout, "Events on object %s (0x%llx), nelemp %d:\n",
170 object, eventset, nelemp);
172 for (i = 0; i < nelemp; i++) {
173 if (!DMEV_ISSET(i, eventset))
176 case DM_EVENT_CANCEL:
177 fprintf(stdout, "DM_EVENT_CANCEL");
180 fprintf(stdout, "DM_EVENT_MOUNT");
182 case DM_EVENT_PREUNMOUNT:
183 fprintf(stdout, "DM_EVENT_PREUNMOUNT");
185 case DM_EVENT_UNMOUNT:
186 fprintf(stdout, "DM_EVENT_UNMOUNT");
189 fprintf(stdout, "DM_EVENT_DEBUT");
191 case DM_EVENT_CREATE:
192 fprintf(stdout, "DM_EVENT_CREATE");
195 fprintf(stdout, "DM_EVENT_CLOSE");
197 case DM_EVENT_POSTCREATE:
198 fprintf(stdout, "DM_EVENT_POSTCREATE");
200 case DM_EVENT_REMOVE:
201 fprintf(stdout, "DM_EVENT_REMOVE");
203 case DM_EVENT_POSTREMOVE:
204 fprintf(stdout, "DM_EVENT_POSTREMOVE");
206 case DM_EVENT_RENAME:
207 fprintf(stdout, "DM_EVENT_RENAME");
209 case DM_EVENT_POSTRENAME:
210 fprintf(stdout, "DM_EVENT_POSTRENAME");
213 fprintf(stdout, "DM_EVENT_LINK");
215 case DM_EVENT_POSTLINK:
216 fprintf(stdout, "DM_EVENT_POSTLINK");
218 case DM_EVENT_SYMLINK:
219 fprintf(stdout, "DM_EVENT_SYMLINK");
221 case DM_EVENT_POSTSYMLINK:
222 fprintf(stdout, "DM_EVENT_POSTSYMLINK");
225 fprintf(stdout, "DM_EVENT_READ");
228 fprintf(stdout, "DM_EVENT_WRITE");
230 case DM_EVENT_TRUNCATE:
231 fprintf(stdout, "DM_EVENT_TRUNCATE");
233 case DM_EVENT_ATTRIBUTE:
234 fprintf(stdout, "DM_EVENT_ATTRIBUTE");
236 case DM_EVENT_DESTROY:
237 fprintf(stdout, "DM_EVENT_DESTROY");
239 case DM_EVENT_NOSPACE:
240 fprintf(stdout, "DM_EVENT_NOSPACE");
243 fprintf(stdout, "DM_EVENT_USER");
246 fprintf(stdout, "DM_EVENT_23");
249 fprintf(stdout, " (%d)\n", i);
252 dm_handle_free(hanp, hlen);