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/
38 /*---------------------------------------------------------------------------
40 Test program used to test the DMAPI function dm_get_eventlist(). The
43 get_eventlist [-F] [-n nelem] [-s sid] [-t token] {pathname|handle}
47 is the pathname of a file or filesystem or a handle.
49 is the value to use for the nelem parameter to dm_get_eventlist().
51 is the dm_sessid_t to use in place of the default test session.
53 is the dm_token_t to use in place of DM_NO_TOKEN.
55 is used when a pathname is specified to indicate that you want its
56 filesystem handle, not its file handle.
58 ----------------------------------------------------------------------------*/
71 fprintf(stderr, "usage:\t%s [-F] [-n nelem] [-s sid] [-t token] "
72 "{pathname|handle}\n",
83 dm_sessid_t sid = DM_NO_SESSION;
84 dm_token_t token = DM_NO_TOKEN;
85 u_int nelem = DM_EVENT_MAX;
87 dm_eventset_t eventset;
97 if (Progname = strrchr(argv[0], '/')) {
103 /* Crack and validate the command line options. */
105 while ((opt = getopt(argc, argv, "Fn:s:t:")) != EOF) {
111 nelem = atol(optarg);
117 token = atol(optarg);
123 if (optind + 1 != argc)
125 object = argv[optind];
127 if (dm_init_service(&name) == -1) {
128 fprintf(stderr, "Can't initialize the DMAPI\n");
132 if ((error = opaque_to_handle(object, &hanp, &hlen)) != 0) {
133 fprintf(stderr, "can't get a handle from %s, %s\n",
134 object, strerror(error));
142 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
143 fprintf(stderr, "can't get filesystem handle from %s\n",
147 dm_handle_free(hanp, hlen);
152 if (sid == DM_NO_SESSION)
153 find_test_session(&sid);
157 if (dm_get_eventlist(sid, hanp, hlen, token, nelem,
158 &eventset, &nelemp)) {
159 fprintf(stderr, "dm_get_eventlist failed, %s\n",
165 fprintf(stdout, "Events on object %s (0x%x), nelemp %d:\n",
167 fprintf(stdout, "Events on object %s (0x%llx), nelemp %d:\n",
169 object, eventset, nelemp);
171 for (i = 0; i < nelemp; i++) {
172 if (!DMEV_ISSET(i, eventset))
175 case DM_EVENT_CANCEL:
176 fprintf(stdout, "DM_EVENT_CANCEL");
179 fprintf(stdout, "DM_EVENT_MOUNT");
181 case DM_EVENT_PREUNMOUNT:
182 fprintf(stdout, "DM_EVENT_PREUNMOUNT");
184 case DM_EVENT_UNMOUNT:
185 fprintf(stdout, "DM_EVENT_UNMOUNT");
188 fprintf(stdout, "DM_EVENT_DEBUT");
190 case DM_EVENT_CREATE:
191 fprintf(stdout, "DM_EVENT_CREATE");
194 fprintf(stdout, "DM_EVENT_CLOSE");
196 case DM_EVENT_POSTCREATE:
197 fprintf(stdout, "DM_EVENT_POSTCREATE");
199 case DM_EVENT_REMOVE:
200 fprintf(stdout, "DM_EVENT_REMOVE");
202 case DM_EVENT_POSTREMOVE:
203 fprintf(stdout, "DM_EVENT_POSTREMOVE");
205 case DM_EVENT_RENAME:
206 fprintf(stdout, "DM_EVENT_RENAME");
208 case DM_EVENT_POSTRENAME:
209 fprintf(stdout, "DM_EVENT_POSTRENAME");
212 fprintf(stdout, "DM_EVENT_LINK");
214 case DM_EVENT_POSTLINK:
215 fprintf(stdout, "DM_EVENT_POSTLINK");
217 case DM_EVENT_SYMLINK:
218 fprintf(stdout, "DM_EVENT_SYMLINK");
220 case DM_EVENT_POSTSYMLINK:
221 fprintf(stdout, "DM_EVENT_POSTSYMLINK");
224 fprintf(stdout, "DM_EVENT_READ");
227 fprintf(stdout, "DM_EVENT_WRITE");
229 case DM_EVENT_TRUNCATE:
230 fprintf(stdout, "DM_EVENT_TRUNCATE");
232 case DM_EVENT_ATTRIBUTE:
233 fprintf(stdout, "DM_EVENT_ATTRIBUTE");
235 case DM_EVENT_DESTROY:
236 fprintf(stdout, "DM_EVENT_DESTROY");
238 case DM_EVENT_NOSPACE:
239 fprintf(stdout, "DM_EVENT_NOSPACE");
242 fprintf(stdout, "DM_EVENT_USER");
245 fprintf(stdout, "DM_EVENT_23");
248 fprintf(stdout, " (%d)\n", i);
251 dm_handle_free(hanp, hlen);