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_config_events(). The
17 get_config_events [-n nelem] handle
19 where handle is the handle of a file or filesystem, and nelem is the value
20 to use for the nelem parameter to dm_get_eventlist().
22 ----------------------------------------------------------------------------*/
35 fprintf(stderr, "usage:\t%s [-n nelem] handle\n", Progname);
45 u_int nelem = DM_EVENT_MAX;
47 dm_eventset_t eventset;
56 Progname = strrchr(argv[0], '/');
63 /* Crack and validate the command line options. */
65 while ((opt = getopt(argc, argv, "n:")) != EOF) {
74 if (optind + 1 != argc)
76 han_str = argv[optind];
77 if ((error = atohan(han_str, &hanp, &hlen)) != 0) {
78 fprintf(stderr, "atohan() failed, %s\n", strerror(error));
82 if (dm_init_service(&name)) {
83 fprintf(stderr, "Can't initialize the DMAPI\n");
89 if (dm_get_config_events(hanp, hlen, nelem, &eventset, &nelemp)) {
90 fprintf(stderr, "dm_get_config_events failed, %s\n",
95 fprintf(stdout, "Events supported (0x%llx), nelemp %d:\n",
96 (unsigned long long) eventset, nelemp);
98 for (i = 0; i < nelemp; i++) {
99 if (!DMEV_ISSET(i, eventset))
102 case DM_EVENT_CANCEL:
103 fprintf(stdout, "DM_EVENT_CANCEL");
106 fprintf(stdout, "DM_EVENT_MOUNT");
108 case DM_EVENT_PREUNMOUNT:
109 fprintf(stdout, "DM_EVENT_PREUNMOUNT");
111 case DM_EVENT_UNMOUNT:
112 fprintf(stdout, "DM_EVENT_UNMOUNT");
115 fprintf(stdout, "DM_EVENT_DEBUT");
117 case DM_EVENT_CREATE:
118 fprintf(stdout, "DM_EVENT_CREATE");
121 fprintf(stdout, "DM_EVENT_CLOSE");
123 case DM_EVENT_POSTCREATE:
124 fprintf(stdout, "DM_EVENT_POSTCREATE");
126 case DM_EVENT_REMOVE:
127 fprintf(stdout, "DM_EVENT_REMOVE");
129 case DM_EVENT_POSTREMOVE:
130 fprintf(stdout, "DM_EVENT_POSTREMOVE");
132 case DM_EVENT_RENAME:
133 fprintf(stdout, "DM_EVENT_RENAME");
135 case DM_EVENT_POSTRENAME:
136 fprintf(stdout, "DM_EVENT_POSTRENAME");
139 fprintf(stdout, "DM_EVENT_LINK");
141 case DM_EVENT_POSTLINK:
142 fprintf(stdout, "DM_EVENT_POSTLINK");
144 case DM_EVENT_SYMLINK:
145 fprintf(stdout, "DM_EVENT_SYMLINK");
147 case DM_EVENT_POSTSYMLINK:
148 fprintf(stdout, "DM_EVENT_POSTSYMLINK");
151 fprintf(stdout, "DM_EVENT_READ");
154 fprintf(stdout, "DM_EVENT_WRITE");
156 case DM_EVENT_TRUNCATE:
157 fprintf(stdout, "DM_EVENT_TRUNCATE");
159 case DM_EVENT_ATTRIBUTE:
160 fprintf(stdout, "DM_EVENT_ATTRIBUTE");
162 case DM_EVENT_DESTROY:
163 fprintf(stdout, "DM_EVENT_DESTROY");
165 case DM_EVENT_NOSPACE:
166 fprintf(stdout, "DM_EVENT_NOSPACE");
169 fprintf(stdout, "DM_EVENT_USER");
172 fprintf(stdout, "DM_EVENT_23");
175 fprintf(stdout, " (%d)\n", i);
178 dm_handle_free(hanp, hlen);