1 /*
2 * Copyright (c) International Business Machines Corp., 2004
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 /*
20 * TEST CASE : dm_impl.h
21 *
22 * PURPOSE : Define implementation-dependent functions and variables
23 * common to all DMAPI test cases
24 *
25 * NOTES : The validEvents[] table is derived from the XDSM
26 * specification, and then the row(s) for unsupported event(s)
27 * are set to DM_FALSE. The definition from the specification
28 * is:
29 *
30 * eventValidity_t validEvents[DM_EVENT_MAX] = {
31 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CANCEL" },
32 * { DM_TRUE , DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_MOUNT" },
33 * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_PREUNMOUNT" },
34 * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_UNMOUNT" },
35 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DEBUT" },
36 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_CREATE" },
37 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CLOSE" },
38 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTCREATE" },
39 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_REMOVE" },
40 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTREMOVE" },
41 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_RENAME" },
42 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTRENAME" },
43 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_LINK" },
44 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTLINK" },
45 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_SYMLINK" },
46 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTSYMLINK" },
47 * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_READ" },
48 * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_WRITE" },
49 * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_TRUNCATE" },
50 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_ATTRIBUTE" },
51 * { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DESTROY" },
52 * { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_NOSPACE" },
53 * { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_USER" }
54 * };
55 *
56 */
57
58 #include <sys/mount.h>
59
60 #ifdef JFS
61 configResult_t dmimpl_expectedResults[CONFIG_MAX] = {
62 { "DM_CONFIG_INVALID", 0 },
63 { "DM_CONFIG_BULKALL", DM_FALSE },
64 { "DM_CONFIG_CREATE_BY_HANDLE", DM_FALSE },
65 { "DM_CONFIG_DTIME_OVERLOAD", DM_TRUE },
66 { "DM_CONFIG_LEGACY", DM_TRUE },
67 { "DM_CONFIG_LOCK_UPGRADE", DM_FALSE },
68 { "DM_CONFIG_MAX_ATTR_ON_DESTROY", 256 /* from dmapi_jfs.c */},
69 { "DM_CONFIG_MAX_ATTRIBUTE_SIZE", 0xFFFF /* from jfs_xattr.h */},
70 { "DM_CONFIG_MAX_HANDLE_SIZE", 56 /* from dmapi_kern.h */},
71 { "DM_CONFIG_MAX_MANAGED_REGIONS", 0x7FFFFFFF /* from dmapi_jfs.c */},
72 { "DM_CONFIG_MAX_MESSAGE_DATA", 3960 /* from dmapi_private.h */},
73 { "DM_CONFIG_OBJ_REF", DM_TRUE },
74 { "DM_CONFIG_PENDING", DM_TRUE }, // ?
75 { "DM_CONFIG_PERS_ATTRIBUTES", DM_TRUE },
76 { "DM_CONFIG_PERS_EVENTS", DM_FALSE },
77 { "DM_CONFIG_PERS_INHERIT_ATTRIBS", DM_FALSE },
78 { "DM_CONFIG_PERS_MANAGED_REGIONS", DM_TRUE },
79 { "DM_CONFIG_PUNCH_HOLE", DM_TRUE },
80 { "DM_CONFIG_TOTAL_ATTRIBUTE_SPACE", 0x7FFFFFFF /* from dmapi_jfs.c */},
81 { "DM_CONFIG_WILL_RETRY", DM_TRUE }
82 };
83
84 /* JFS does not support DM_EVENT_CANCEL or DM_EVENT_DEBUT */
85 eventValidity_t dmimpl_validEvents[DM_EVENT_MAX] = {
86 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_CANCEL" },
87 { DM_TRUE , DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_MOUNT" },
88 { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_PREUNMOUNT" },
89 { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_UNMOUNT" },
90 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_DEBUT" },
91 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_CREATE" },
92 { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_CLOSE" },
93 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTCREATE" },
94 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_REMOVE" },
95 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTREMOVE" },
96 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_RENAME" },
97 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTRENAME" },
98 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_LINK" },
99 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTLINK" },
100 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_SYMLINK" },
101 { DM_FALSE, DM_TRUE , DM_TRUE , DM_FALSE , "DM_EVENT_POSTSYMLINK" },
102 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_READ" },
103 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_WRITE" },
104 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_TRUNCATE" },
105 { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_ATTRIBUTE" },
106 { DM_FALSE, DM_TRUE , DM_TRUE , DM_TRUE , "DM_EVENT_DESTROY" },
107 { DM_FALSE, DM_TRUE , DM_FALSE, DM_FALSE , "DM_EVENT_NOSPACE" },
108 { DM_FALSE, DM_FALSE, DM_FALSE, DM_FALSE , "DM_EVENT_USER" }
109 };
110
111 dm_eventset_t dmimpl_eventset =
112 /* (1 << DM_EVENT_CANCEL) | */
113 (1 << DM_EVENT_MOUNT) |
114 (1 << DM_EVENT_PREUNMOUNT) |
115 (1 << DM_EVENT_UNMOUNT) |
116 /* (1 << DM_EVENT_DEBUT) | */
117 (1 << DM_EVENT_CREATE) |
118 (1 << DM_EVENT_CLOSE) |
119 (1 << DM_EVENT_POSTCREATE) |
120 (1 << DM_EVENT_REMOVE) |
121 (1 << DM_EVENT_POSTREMOVE) |
122 (1 << DM_EVENT_RENAME) |
123 (1 << DM_EVENT_POSTRENAME) |
124 (1 << DM_EVENT_LINK) |
125 (1 << DM_EVENT_POSTLINK) |
126 (1 << DM_EVENT_SYMLINK) |
127 (1 << DM_EVENT_POSTSYMLINK) |
128 (1 << DM_EVENT_READ) |
129 (1 << DM_EVENT_WRITE) |
130 (1 << DM_EVENT_TRUNCATE) |
131 (1 << DM_EVENT_ATTRIBUTE) |
132 (1 << DM_EVENT_DESTROY) |
133 (1 << DM_EVENT_NOSPACE) |
134 (1 << DM_EVENT_USER);
135
dmimpl_mount(char ** mountPt,char ** deviceNm)136 int dmimpl_mount(char **mountPt, char **deviceNm) {
137 char options[FILENAME_MAX];
138
139 if ((*mountPt = DMOPT_GET("mtpt")) == NULL) {
140 DMLOG_PRINT(DMLVL_ERR, "Missing mount point, use -mtpt (for example, -mtpt /dmapidir)\n");
141 DM_EXIT();
142 } else {
143 DMLOG_PRINT(DMLVL_DEBUG, "Mount point is %s\n", *mountPt);
144 }
145
146 if ((*deviceNm = DMOPT_GET("device")) == NULL) {
147 DMLOG_PRINT(DMLVL_ERR, "Missing device name, use -device (for example, -device /dev/hda5)\n");
148 DM_EXIT();
149 } else {
150 DMLOG_PRINT(DMLVL_DEBUG, "Device name is %s\n", *deviceNm);
151 }
152
153 sprintf(options, "dmapi,mtpt=%s", *mountPt);
154 EVENT_DELIVERY_DELAY;
155 DMLOG_PRINT(DMLVL_DEBUG, "Mounting %s on %s now...\n", *deviceNm, *mountPt);
156 return mount(*deviceNm, *mountPt, "jfs", 0, options);
157 }
158 #endif
159