* this function is a POSIX compliant version, which will make a directory * * @param path the directory path to be made. * @param mode The permission mode for the new directory (unused here, can be set to 0). * * @return 0 on successful, others on failed. */
| 810 | * @return 0 on successful, others on failed. |
| 811 | */ |
| 812 | int mkdir(const char *path, mode_t mode) |
| 813 | { |
| 814 | int result; |
| 815 | struct stat stat; |
| 816 | struct dfs_file file; |
| 817 | |
| 818 | if (path == NULL) |
| 819 | { |
| 820 | rt_set_errno(-EBADF); |
| 821 | return -1; |
| 822 | } |
| 823 | |
| 824 | if (path && dfs_file_lstat(path, &stat) == 0) |
| 825 | { |
| 826 | rt_set_errno(-EEXIST); |
| 827 | return -1; |
| 828 | } |
| 829 | |
| 830 | dfs_file_init(&file); |
| 831 | |
| 832 | result = dfs_file_open(&file, path, O_DIRECTORY | O_CREAT, mode); |
| 833 | if (result >= 0) |
| 834 | { |
| 835 | dfs_file_close(&file); |
| 836 | result = 0; |
| 837 | } |
| 838 | else |
| 839 | { |
| 840 | rt_set_errno(result); |
| 841 | result = -1; |
| 842 | } |
| 843 | |
| 844 | dfs_file_deinit(&file); |
| 845 | |
| 846 | return result; |
| 847 | } |
| 848 | RTM_EXPORT(mkdir); |
| 849 | |
| 850 | #ifdef RT_USING_FINSH |
no test coverage detected