* @brief Retrieves information about a file associated with a file descriptor. * * This system call retrieves the status information about the file referred to * by the file descriptor `file` and stores it in the structure pointed to by `buf`. * It is typically used to obtain metadata such as file size, permissions, type, * and timestamps. * * @param file The file descriptor referring to an
| 828 | * @see sys_open(), sys_close(), stat(), fstat() |
| 829 | */ |
| 830 | sysret_t sys_fstat(int file, struct stat *buf) |
| 831 | { |
| 832 | #ifdef ARCH_MM_MMU |
| 833 | int ret = -1; |
| 834 | struct stat statbuff = {0}; |
| 835 | |
| 836 | if (!lwp_user_accessable((void *)buf, sizeof(struct stat))) |
| 837 | { |
| 838 | return -EFAULT; |
| 839 | } |
| 840 | else |
| 841 | { |
| 842 | ret = fstat(file, &statbuff); |
| 843 | |
| 844 | if (ret == 0) |
| 845 | { |
| 846 | lwp_put_to_user(buf, &statbuff, sizeof statbuff); |
| 847 | } |
| 848 | else |
| 849 | { |
| 850 | ret = GET_ERRNO(); |
| 851 | } |
| 852 | |
| 853 | return ret; |
| 854 | } |
| 855 | #else |
| 856 | if (!lwp_user_accessable((void *)buf, sizeof(struct stat))) |
| 857 | { |
| 858 | return -EFAULT; |
| 859 | } |
| 860 | int ret = fstat(file, buf); |
| 861 | return (ret < 0 ? GET_ERRNO() : ret); |
| 862 | #endif |
| 863 | } |
| 864 | |
| 865 | /** |
| 866 | * @brief Monitors multiple file descriptors to see if they are ready for I/O. |
nothing calls this directly
no test coverage detected