| 648 | }; |
| 649 | #endif |
| 650 | int |
| 651 | freebsd4_getfsstat(struct thread *td, struct freebsd4_getfsstat_args *uap) |
| 652 | { |
| 653 | struct statfs *buf, *sp; |
| 654 | struct ostatfs osb; |
| 655 | size_t count, size; |
| 656 | int error; |
| 657 | |
| 658 | if (uap->bufsize < 0) |
| 659 | return (EINVAL); |
| 660 | count = uap->bufsize / sizeof(struct ostatfs); |
| 661 | if (count > SIZE_MAX / sizeof(struct statfs)) |
| 662 | return (EINVAL); |
| 663 | size = count * sizeof(struct statfs); |
| 664 | error = kern_getfsstat(td, &buf, size, &count, UIO_SYSSPACE, |
| 665 | uap->mode); |
| 666 | if (error == 0) |
| 667 | td->td_retval[0] = count; |
| 668 | if (size != 0) { |
| 669 | sp = buf; |
| 670 | while (count != 0 && error == 0) { |
| 671 | freebsd4_cvtstatfs(sp, &osb); |
| 672 | error = copyout(&osb, uap->buf, sizeof(osb)); |
| 673 | sp++; |
| 674 | uap->buf++; |
| 675 | count--; |
| 676 | } |
| 677 | free(buf, M_STATFS); |
| 678 | } |
| 679 | return (error); |
| 680 | } |
| 681 | |
| 682 | /* |
| 683 | * Implement fstatfs() for (NFS) file handles. |
nothing calls this directly
no test coverage detected