Print this page
OS-1840 fmdump shall emit JSON (copyright fixes 2)
OS-1840 fmdump shall emit JSON (rm feedback)


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2012 by Delphix. All rights reserved.

  24  */
  25 
  26 #include <sys/nvpair.h>
  27 #include <sys/kmem.h>
  28 #include <sys/debug.h>
  29 #ifndef _KERNEL
  30 #include <stdlib.h>
  31 #endif
  32 



  33 /*
  34  * "Force" nvlist wrapper.
  35  *
  36  * These functions wrap the nvlist_* functions with assertions that assume
  37  * the operation is successful.  This allows the caller's code to be much
  38  * more readable, especially for the fnvlist_lookup_* and fnvpair_value_*
  39  * functions, which can return the requested value (rather than filling in
  40  * a pointer).
  41  *
  42  * These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_NATIVE, and allocate
  43  * with KM_SLEEP.
  44  *
  45  * More wrappers should be added as needed -- for example
  46  * nvlist_lookup_*_array and nvpair_value_*_array.
  47  */
  48 
  49 nvlist_t *
  50 fnvlist_alloc(void)
  51 {
  52         nvlist_t *nvl;


 335         return (rv);
 336 }
 337 
 338 int32_t
 339 fnvlist_lookup_int32(nvlist_t *nvl, const char *name)
 340 {
 341         int32_t rv;
 342         VERIFY0(nvlist_lookup_int32(nvl, name, &rv));
 343         return (rv);
 344 }
 345 
 346 int64_t
 347 fnvlist_lookup_int64(nvlist_t *nvl, const char *name)
 348 {
 349         int64_t rv;
 350         VERIFY0(nvlist_lookup_int64(nvl, name, &rv));
 351         return (rv);
 352 }
 353 
 354 uint8_t
 355 fnvlist_lookup_uint8_t(nvlist_t *nvl, const char *name)
 356 {
 357         uint8_t rv;
 358         VERIFY0(nvlist_lookup_uint8(nvl, name, &rv));
 359         return (rv);
 360 }
 361 
 362 uint16_t
 363 fnvlist_lookup_uint16(nvlist_t *nvl, const char *name)
 364 {
 365         uint16_t rv;
 366         VERIFY0(nvlist_lookup_uint16(nvl, name, &rv));
 367         return (rv);
 368 }
 369 
 370 uint32_t
 371 fnvlist_lookup_uint32(nvlist_t *nvl, const char *name)
 372 {
 373         uint32_t rv;
 374         VERIFY0(nvlist_lookup_uint32(nvl, name, &rv));
 375         return (rv);


 431         return (rv);
 432 }
 433 
 434 int32_t
 435 fnvpair_value_int32(nvpair_t *nvp)
 436 {
 437         int32_t rv;
 438         VERIFY0(nvpair_value_int32(nvp, &rv));
 439         return (rv);
 440 }
 441 
 442 int64_t
 443 fnvpair_value_int64(nvpair_t *nvp)
 444 {
 445         int64_t rv;
 446         VERIFY0(nvpair_value_int64(nvp, &rv));
 447         return (rv);
 448 }
 449 
 450 uint8_t
 451 fnvpair_value_uint8_t(nvpair_t *nvp)
 452 {
 453         uint8_t rv;
 454         VERIFY0(nvpair_value_uint8(nvp, &rv));
 455         return (rv);
 456 }
 457 
 458 uint16_t
 459 fnvpair_value_uint16(nvpair_t *nvp)
 460 {
 461         uint16_t rv;
 462         VERIFY0(nvpair_value_uint16(nvp, &rv));
 463         return (rv);
 464 }
 465 
 466 uint32_t
 467 fnvpair_value_uint32(nvpair_t *nvp)
 468 {
 469         uint32_t rv;
 470         VERIFY0(nvpair_value_uint32(nvp, &rv));
 471         return (rv);


 477         uint64_t rv;
 478         VERIFY0(nvpair_value_uint64(nvp, &rv));
 479         return (rv);
 480 }
 481 
 482 char *
 483 fnvpair_value_string(nvpair_t *nvp)
 484 {
 485         char *rv;
 486         VERIFY0(nvpair_value_string(nvp, &rv));
 487         return (rv);
 488 }
 489 
 490 nvlist_t *
 491 fnvpair_value_nvlist(nvpair_t *nvp)
 492 {
 493         nvlist_t *rv;
 494         VERIFY0(nvpair_value_nvlist(nvp, &rv));
 495         return (rv);
 496 }


















   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2012 by Delphix. All rights reserved.
  24  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  25  */
  26 
  27 #include <sys/nvpair.h>
  28 #include <sys/kmem.h>
  29 #include <sys/debug.h>
  30 #ifndef _KERNEL
  31 #include <stdlib.h>
  32 #endif
  33 
  34 #pragma weak fnvlist_lookup_uint8_t = fnvlist_lookup_uint8
  35 #pragma weak fnvpair_value_uint8_t = fnvpair_value_uint8
  36 
  37 /*
  38  * "Force" nvlist wrapper.
  39  *
  40  * These functions wrap the nvlist_* functions with assertions that assume
  41  * the operation is successful.  This allows the caller's code to be much
  42  * more readable, especially for the fnvlist_lookup_* and fnvpair_value_*
  43  * functions, which can return the requested value (rather than filling in
  44  * a pointer).
  45  *
  46  * These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_NATIVE, and allocate
  47  * with KM_SLEEP.
  48  *
  49  * More wrappers should be added as needed -- for example
  50  * nvlist_lookup_*_array and nvpair_value_*_array.
  51  */
  52 
  53 nvlist_t *
  54 fnvlist_alloc(void)
  55 {
  56         nvlist_t *nvl;


 339         return (rv);
 340 }
 341 
 342 int32_t
 343 fnvlist_lookup_int32(nvlist_t *nvl, const char *name)
 344 {
 345         int32_t rv;
 346         VERIFY0(nvlist_lookup_int32(nvl, name, &rv));
 347         return (rv);
 348 }
 349 
 350 int64_t
 351 fnvlist_lookup_int64(nvlist_t *nvl, const char *name)
 352 {
 353         int64_t rv;
 354         VERIFY0(nvlist_lookup_int64(nvl, name, &rv));
 355         return (rv);
 356 }
 357 
 358 uint8_t
 359 fnvlist_lookup_uint8(nvlist_t *nvl, const char *name)
 360 {
 361         uint8_t rv;
 362         VERIFY0(nvlist_lookup_uint8(nvl, name, &rv));
 363         return (rv);
 364 }
 365 
 366 uint16_t
 367 fnvlist_lookup_uint16(nvlist_t *nvl, const char *name)
 368 {
 369         uint16_t rv;
 370         VERIFY0(nvlist_lookup_uint16(nvl, name, &rv));
 371         return (rv);
 372 }
 373 
 374 uint32_t
 375 fnvlist_lookup_uint32(nvlist_t *nvl, const char *name)
 376 {
 377         uint32_t rv;
 378         VERIFY0(nvlist_lookup_uint32(nvl, name, &rv));
 379         return (rv);


 435         return (rv);
 436 }
 437 
 438 int32_t
 439 fnvpair_value_int32(nvpair_t *nvp)
 440 {
 441         int32_t rv;
 442         VERIFY0(nvpair_value_int32(nvp, &rv));
 443         return (rv);
 444 }
 445 
 446 int64_t
 447 fnvpair_value_int64(nvpair_t *nvp)
 448 {
 449         int64_t rv;
 450         VERIFY0(nvpair_value_int64(nvp, &rv));
 451         return (rv);
 452 }
 453 
 454 uint8_t
 455 fnvpair_value_uint8(nvpair_t *nvp)
 456 {
 457         uint8_t rv;
 458         VERIFY0(nvpair_value_uint8(nvp, &rv));
 459         return (rv);
 460 }
 461 
 462 uint16_t
 463 fnvpair_value_uint16(nvpair_t *nvp)
 464 {
 465         uint16_t rv;
 466         VERIFY0(nvpair_value_uint16(nvp, &rv));
 467         return (rv);
 468 }
 469 
 470 uint32_t
 471 fnvpair_value_uint32(nvpair_t *nvp)
 472 {
 473         uint32_t rv;
 474         VERIFY0(nvpair_value_uint32(nvp, &rv));
 475         return (rv);


 481         uint64_t rv;
 482         VERIFY0(nvpair_value_uint64(nvp, &rv));
 483         return (rv);
 484 }
 485 
 486 char *
 487 fnvpair_value_string(nvpair_t *nvp)
 488 {
 489         char *rv;
 490         VERIFY0(nvpair_value_string(nvp, &rv));
 491         return (rv);
 492 }
 493 
 494 nvlist_t *
 495 fnvpair_value_nvlist(nvpair_t *nvp)
 496 {
 497         nvlist_t *rv;
 498         VERIFY0(nvpair_value_nvlist(nvp, &rv));
 499         return (rv);
 500 }
 501 
 502 double
 503 fnvpair_value_double(nvpair_t *nvp)
 504 {
 505         double rv;
 506         VERIFY0(nvpair_value_double(nvp, &rv));
 507         return (rv);
 508 }
 509 
 510 hrtime_t
 511 fnvpair_value_hrtime(nvpair_t *nvp)
 512 {
 513         hrtime_t rv;
 514         VERIFY0(nvpair_value_hrtime(nvp, &rv));
 515         return (rv);
 516 }