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