* @brief Removes the specified directory. * * This function removes the directory specified by the given path. The directory * must be empty for the operation to succeed. If the directory is not empty, the * function will return an error. If the directory does not exist or the process * lacks the necessary permissions, the function will also return an error. * * @param[in] path The path
| 7645 | * @see sys_mkdir(), sys_chdir(), sys_rmdirat() |
| 7646 | */ |
| 7647 | sysret_t sys_rmdir(const char *path) |
| 7648 | { |
| 7649 | int err = 0; |
| 7650 | int ret = 0; |
| 7651 | #ifdef ARCH_MM_MMU |
| 7652 | int len = 0; |
| 7653 | char *kpath = RT_NULL; |
| 7654 | |
| 7655 | len = lwp_user_strlen(path); |
| 7656 | if (len <= 0) |
| 7657 | { |
| 7658 | return -EFAULT; |
| 7659 | } |
| 7660 | |
| 7661 | kpath = (char *)kmem_get(len + 1); |
| 7662 | if (!kpath) |
| 7663 | { |
| 7664 | return -ENOMEM; |
| 7665 | } |
| 7666 | |
| 7667 | if (lwp_get_from_user(kpath, (void *)path, len + 1) != (len + 1)) |
| 7668 | { |
| 7669 | kmem_put(kpath); |
| 7670 | return -EINVAL; |
| 7671 | } |
| 7672 | |
| 7673 | ret = rmdir(kpath); |
| 7674 | if(ret < 0) |
| 7675 | { |
| 7676 | err = GET_ERRNO(); |
| 7677 | } |
| 7678 | |
| 7679 | kmem_put(kpath); |
| 7680 | |
| 7681 | return (err < 0 ? err : ret); |
| 7682 | #else |
| 7683 | ret = rmdir(path); |
| 7684 | if(ret < 0) |
| 7685 | { |
| 7686 | err = GET_ERRNO(); |
| 7687 | } |
| 7688 | return (err < 0 ? err : ret); |
| 7689 | #endif |
| 7690 | } |
| 7691 | |
| 7692 | /** |
| 7693 | * @brief Reads directory entries. |
nothing calls this directly
no test coverage detected