* Given a preloaded module handle (mod), return a pointer * to the data for the attribute (inf). */
| 161 | * to the data for the attribute (inf). |
| 162 | */ |
| 163 | caddr_t |
| 164 | preload_search_info(caddr_t mod, int inf) |
| 165 | { |
| 166 | caddr_t curp; |
| 167 | uint32_t *hdr; |
| 168 | uint32_t type = 0; |
| 169 | int next; |
| 170 | |
| 171 | if (mod == NULL) |
| 172 | return (NULL); |
| 173 | |
| 174 | curp = mod; |
| 175 | for (;;) { |
| 176 | hdr = (uint32_t *)curp; |
| 177 | /* end of module data? */ |
| 178 | if (hdr[0] == 0 && hdr[1] == 0) |
| 179 | break; |
| 180 | /* |
| 181 | * We give up once we've looped back to what we were looking at |
| 182 | * first - this should normally be a MODINFO_NAME field. |
| 183 | */ |
| 184 | if (type == 0) { |
| 185 | type = hdr[0]; |
| 186 | } else { |
| 187 | if (hdr[0] == type) |
| 188 | break; |
| 189 | } |
| 190 | |
| 191 | /* |
| 192 | * Attribute match? Return pointer to data. |
| 193 | * Consumer may safely assume that size value precedes |
| 194 | * data. |
| 195 | */ |
| 196 | if (hdr[0] == inf) |
| 197 | return(curp + (sizeof(uint32_t) * 2)); |
| 198 | |
| 199 | /* skip to next field */ |
| 200 | next = sizeof(uint32_t) * 2 + hdr[1]; |
| 201 | next = roundup(next, sizeof(u_long)); |
| 202 | curp += next; |
| 203 | } |
| 204 | return(NULL); |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * Delete a preload record by name. |
no outgoing calls
no test coverage detected