Changes in kernel/generic/src/sysinfo/sysinfo.c [7a0359b:311bc25] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/sysinfo/sysinfo.c
r7a0359b r311bc25 40 40 #include <arch/asm.h> 41 41 #include <errno.h> 42 #include <macros.h> 42 43 43 44 /** Maximal sysinfo path length */ … … 296 297 */ 297 298 void sysinfo_set_item_val(const char *name, sysinfo_item_t **root, 298 unative_t val)299 sysarg_t val) 299 300 { 300 301 /* Protect sysinfo tree consistency */ … … 481 482 sysinfo_indent(depth); 482 483 483 unative_t val;484 sysarg_t val; 484 485 size_t size; 485 486 … … 494 495 break; 495 496 case SYSINFO_VAL_DATA: 496 printf("+ %s (% " PRIs"bytes)\n", cur->name,497 printf("+ %s (%zu bytes)\n", cur->name, 497 498 cur->val.data.size); 498 499 break; … … 505 506 /* N.B.: No data was actually returned (only a dry run) */ 506 507 (void) cur->val.fn_data(cur, &size, true); 507 printf("+ %s (% " PRIs"bytes) [generated]\n", cur->name,508 printf("+ %s (%zu bytes) [generated]\n", cur->name, 508 509 size); 509 510 break; … … 660 661 * 661 662 */ 662 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size)663 sysarg_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size) 663 664 { 664 665 /* … … 679 680 ret.tag = SYSINFO_VAL_DATA; 680 681 681 return ( unative_t) ret.tag;682 return (sysarg_t) ret.tag; 682 683 } 683 684 … … 696 697 * 697 698 */ 698 unative_t sys_sysinfo_get_value(void *path_ptr, size_t path_size,699 sysarg_t sys_sysinfo_get_value(void *path_ptr, size_t path_size, 699 700 void *value_ptr) 700 701 { … … 715 716 rc = EINVAL; 716 717 717 return ( unative_t) rc;718 return (sysarg_t) rc; 718 719 } 719 720 … … 732 733 * 733 734 */ 734 unative_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size,735 sysarg_t sys_sysinfo_get_data_size(void *path_ptr, size_t path_size, 735 736 void *size_ptr) 736 737 { … … 752 753 rc = EINVAL; 753 754 754 return ( unative_t) rc;755 return (sysarg_t) rc; 755 756 } 756 757 … … 761 762 * character must be null). 762 763 * 763 * The user space buffer must be sized exactly according 764 * to the size of the binary data, otherwise the request 765 * fails. 764 * If the user space buffer size does not equal 765 * the actual size of the returned data, the data 766 * is truncated. Whether this is actually a fatal 767 * error or the data can be still interpreted as valid 768 * depends on the nature of the data and has to be 769 * decided by the user space. 770 * 771 * The actual size of data returned is stored to 772 * size_ptr. 766 773 * 767 774 * @param path_ptr Sysinfo path in the user address space. … … 770 777 * to store the binary data. 771 778 * @param buffer_size User space buffer size. 779 * @param size_ptr User space pointer where to store the 780 * binary data size. 772 781 * 773 782 * @return Error code (EOK in case of no error). 774 783 * 775 784 */ 776 unative_t sys_sysinfo_get_data(void *path_ptr, size_t path_size,777 void *buffer_ptr, size_t buffer_size )785 sysarg_t sys_sysinfo_get_data(void *path_ptr, size_t path_size, 786 void *buffer_ptr, size_t buffer_size, size_t *size_ptr) 778 787 { 779 788 int rc; 780 789 781 790 /* Get the item */ 782 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, false); 783 791 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, 792 false); 793 784 794 /* Only constant or generated binary data is considered */ 785 if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) { 786 /* Check destination buffer size */ 787 if (ret.data.size == buffer_size) 788 rc = copy_to_uspace(buffer_ptr, ret.data.data, 789 ret.data.size); 790 else 791 rc = ENOMEM; 795 if ((ret.tag == SYSINFO_VAL_DATA) || 796 (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) { 797 size_t size = min(ret.data.size, buffer_size); 798 rc = copy_to_uspace(buffer_ptr, ret.data.data, size); 799 if (rc == EOK) 800 rc = copy_to_uspace(size_ptr, &size, sizeof(size)); 792 801 } else 793 802 rc = EINVAL; … … 797 806 free(ret.data.data); 798 807 799 return ( unative_t) rc;808 return (sysarg_t) rc; 800 809 } 801 810
Note:
See TracChangeset
for help on using the changeset viewer.