1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
12 /*---------------------------------------------------------------------------
14 Test program used to test the DMAPI function dm_get_eventlist(). The
17 get_eventlist [-F] [-n nelem] [-s sid] [-t token] {pathname|handle}
21 is the pathname of a file or filesystem or a handle.
23 is the value to use for the nelem parameter to dm_get_eventlist().
25 is the dm_sessid_t to use in place of the default test session.
27 is the dm_token_t to use in place of DM_NO_TOKEN.
29 is used when a pathname is specified to indicate that you want its
30 filesystem handle, not its file handle.
32 ----------------------------------------------------------------------------*/
45 fprintf(stderr, "usage:\t%s [-F] [-n nelem] [-s sid] [-t token] "
46 "{pathname|handle}\n",
57 dm_sessid_t sid = DM_NO_SESSION;
58 dm_token_t token = DM_NO_TOKEN;
59 u_int nelem = DM_EVENT_MAX;
61 dm_eventset_t eventset;
71 Progname = strrchr(argv[0], '/');
78 /* Crack and validate the command line options. */
80 while ((opt = getopt(argc, argv, "Fn:s:t:")) != EOF) {
98 if (optind + 1 != argc)
100 object = argv[optind];
102 if (dm_init_service(&name) == -1) {
103 fprintf(stderr, "Can't initialize the DMAPI\n");
107 if ((error = opaque_to_handle(object, &hanp, &hlen)) != 0) {
108 fprintf(stderr, "can't get a handle from %s, %s\n",
109 object, strerror(error));
117 if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
118 fprintf(stderr, "can't get filesystem handle from %s\n",
122 dm_handle_free(hanp, hlen);
127 if (sid == DM_NO_SESSION)
128 find_test_session(&sid);
132 if (dm_get_eventlist(sid, hanp, hlen, token, nelem,
133 &eventset, &nelemp)) {
134 fprintf(stderr, "dm_get_eventlist failed, %s\n",
139 fprintf(stdout, "Events on object %s (0x%llx), nelemp %d:\n",
140 object, (unsigned long long) eventset, nelemp);
142 for (i = 0; i < nelemp; i++) {
143 if (!DMEV_ISSET(i, eventset))
146 case DM_EVENT_CANCEL:
147 fprintf(stdout, "DM_EVENT_CANCEL");
150 fprintf(stdout, "DM_EVENT_MOUNT");
152 case DM_EVENT_PREUNMOUNT:
153 fprintf(stdout, "DM_EVENT_PREUNMOUNT");
155 case DM_EVENT_UNMOUNT:
156 fprintf(stdout, "DM_EVENT_UNMOUNT");
159 fprintf(stdout, "DM_EVENT_DEBUT");
161 case DM_EVENT_CREATE:
162 fprintf(stdout, "DM_EVENT_CREATE");
165 fprintf(stdout, "DM_EVENT_CLOSE");
167 case DM_EVENT_POSTCREATE:
168 fprintf(stdout, "DM_EVENT_POSTCREATE");
170 case DM_EVENT_REMOVE:
171 fprintf(stdout, "DM_EVENT_REMOVE");
173 case DM_EVENT_POSTREMOVE:
174 fprintf(stdout, "DM_EVENT_POSTREMOVE");
176 case DM_EVENT_RENAME:
177 fprintf(stdout, "DM_EVENT_RENAME");
179 case DM_EVENT_POSTRENAME:
180 fprintf(stdout, "DM_EVENT_POSTRENAME");
183 fprintf(stdout, "DM_EVENT_LINK");
185 case DM_EVENT_POSTLINK:
186 fprintf(stdout, "DM_EVENT_POSTLINK");
188 case DM_EVENT_SYMLINK:
189 fprintf(stdout, "DM_EVENT_SYMLINK");
191 case DM_EVENT_POSTSYMLINK:
192 fprintf(stdout, "DM_EVENT_POSTSYMLINK");
195 fprintf(stdout, "DM_EVENT_READ");
198 fprintf(stdout, "DM_EVENT_WRITE");
200 case DM_EVENT_TRUNCATE:
201 fprintf(stdout, "DM_EVENT_TRUNCATE");
203 case DM_EVENT_ATTRIBUTE:
204 fprintf(stdout, "DM_EVENT_ATTRIBUTE");
206 case DM_EVENT_DESTROY:
207 fprintf(stdout, "DM_EVENT_DESTROY");
209 case DM_EVENT_NOSPACE:
210 fprintf(stdout, "DM_EVENT_NOSPACE");
213 fprintf(stdout, "DM_EVENT_USER");
216 fprintf(stdout, "DM_EVENT_23");
219 fprintf(stdout, " (%d)\n", i);
222 dm_handle_free(hanp, hlen);