Changeset b94c5ec in rtems-libbsd
- Timestamp:
- 11/03/14 14:21:06 (8 years ago)
- Branches:
- 4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
- Children:
- 7ba9b7f
- Parents:
- f90fdf3
- git-author:
- Sebastian Huber <sebastian.huber@…> (11/03/14 14:21:06)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (11/04/14 12:02:55)
- Location:
- freebsd
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
freebsd/include/nsswitch.h
rf90fdf3 rb94c5ec 216 216 ns_mtab *mtab; /* method table */ 217 217 unsigned int mtabsize; /* count of entries in method table */ 218 #ifndef __rtems__ 218 219 nss_module_unregister_fn unregister; /* called to unload module */ 220 #endif /* __rtems__ */ 219 221 } ns_mod; 220 222 … … 239 241 #endif 240 242 #endif /* _NS_PRIVATE */ 243 #ifdef __rtems__ 244 /** 245 * @brief Registers a name service module. 246 * 247 * @param[in] source The source identifier. 248 * @param[in] mtab The module table. This table will be claimed by the name 249 * service dispatcher. 250 * @param[in] mtabsize The module table entry count. 251 * 252 * @retval 0 Successful operation. 253 * @retval -1 An error occurred. The errno is set to indicate the error. 254 */ 255 int 256 rtems_nss_register_module(const char *source, ns_mtab *mtab, 257 unsigned int mtabsize); 258 #endif /* __rtems__ */ 241 259 242 260 __END_DECLS -
freebsd/lib/libc/net/nsdispatch.c
rf90fdf3 rb94c5ec 133 133 static ns_mod *_nsmod; 134 134 135 #ifndef __rtems__ 135 136 /* Placeholder for builtin modules' dlopen `handle'. */ 136 137 static int __nss_builtin_handle; 137 138 static void *nss_builtin_handle = &__nss_builtin_handle; 139 #endif /* __rtems__ */ 138 140 139 141 #ifdef NS_CACHING … … 190 192 static int nss_configure(void); 191 193 static void ns_dbt_free(ns_dbt *); 194 #ifndef __rtems__ 192 195 static void ns_mod_free(ns_mod *); 196 #endif /* __rtems__ */ 193 197 static void ns_src_free(ns_src **, int); 198 #ifndef __rtems__ 194 199 static void nss_load_builtin_modules(void); 195 200 static void nss_load_module(const char *, nss_module_register_fn); 196 201 static void nss_atexit(void); 202 #endif /* __rtems__ */ 197 203 /* nsparser */ 198 204 extern FILE *_nsyyin; … … 300 306 modp = vector_search(&src->name, _nsmod, _nsmodsize, sizeof(*_nsmod), 301 307 string_compare); 308 #ifndef __rtems__ 302 309 if (modp == NULL) 303 310 nss_load_module(src->name, NULL); 311 #else /* __rtems__ */ 312 (void)modp; 313 #endif /* __rtems__ */ 304 314 } 305 315 … … 380 390 VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), 381 391 (vector_free_elem)ns_dbt_free); 392 #ifndef __rtems__ 382 393 VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), 383 394 (vector_free_elem)ns_mod_free); 384 395 nss_load_builtin_modules(); 396 #endif /* __rtems__ */ 385 397 _nsyyparse(); 386 398 (void)fclose(_nsyyin); 387 399 vector_sort(_nsmap, _nsmapsize, sizeof(*_nsmap), string_compare); 400 #ifndef __rtems__ 388 401 if (confmod == 0) 389 402 (void)atexit(nss_atexit); 403 #endif /* __rtems__ */ 390 404 confmod = statbuf.st_mtime; 391 405 … … 457 471 458 472 473 #ifndef __rtems__ 459 474 /* 460 475 * NSS module management. … … 500 515 } else if (!is_dynamic()) 501 516 goto fin; 502 #ifndef __rtems__503 517 else { 504 518 if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name, … … 524 538 } 525 539 } 526 #endif /* __rtems__ */527 540 mod.mtab = fn(mod.name, &mod.mtabsize, &mod.unregister); 528 541 if (mod.mtab == NULL || mod.mtabsize == 0) { 529 #ifndef __rtems__530 542 if (mod.handle != nss_builtin_handle) 531 543 (void)dlclose(mod.handle); 532 #endif /* __rtems__ */533 544 mod.handle = NULL; 534 545 nss_log(LOG_ERR, "%s, registration failed", mod.name); … … 554 565 if (mod->unregister != NULL) 555 566 mod->unregister(mod->mtab, mod->mtabsize); 556 #ifndef __rtems__557 567 if (mod->handle != nss_builtin_handle) 558 568 (void)dlclose(mod->handle); 559 #endif /* __rtems__ */560 569 } 561 570 … … 580 589 (void)_pthread_rwlock_unlock(&nss_lock); 581 590 } 591 #else /* __rtems__ */ 592 int 593 rtems_nss_register_module(const char *source, ns_mtab *mtab, 594 unsigned int mtabsize) 595 { 596 ns_mod mod; 597 int result; 598 599 if (mtab == NULL || mtabsize == 0) { 600 errno = EINVAL; 601 return -1; 602 } 603 604 memset(&mod, 0, sizeof(mod)); 605 mod.name = strdup(source); 606 if (mod.name == NULL) { 607 return -1; 608 } 609 mod.handle = (void *)1; 610 mod.mtab = mtab; 611 mod.mtabsize = mtabsize; 612 qsort(mod.mtab, mod.mtabsize, sizeof(mod.mtab[0]), mtab_compare); 613 614 result = _pthread_rwlock_wrlock(&nss_lock); 615 if (result != 0) { 616 errno = result; 617 return -1; 618 } 619 620 _nsmod = vector_append(&mod, _nsmod, &_nsmodsize, sizeof(*_nsmod)); 621 vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare); 622 623 (void)_pthread_rwlock_unlock(&nss_lock); 624 625 return 0; 626 } 627 #endif /* __rtems__ */ 582 628 583 629
Note: See TracChangeset
for help on using the changeset viewer.