Changeset 128a311 in mainline for uspace/lib/c/generic/dirent.c
- Timestamp:
- 2026-03-17T12:37:31Z (32 hours ago)
- Children:
- 8c35ebd
- Parents:
- df4f7c30
- git-author:
- Vít Skalický <skalicky@…> (2026-03-16 14:27:57)
- git-committer:
- Vít Skalický <skalicky@…> (2026-03-17 12:37:31)
- File:
-
- 1 edited
-
uspace/lib/c/generic/dirent.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/dirent.c
rdf4f7c30 r128a311 47 47 }; 48 48 49 /** Open directory by its handle (a.k.a. file descriptor). 50 * 51 * @param handle Directory handle 52 * @return Non-NULL pointer on success. On error returns @c NULL and sets errno. 53 */ 54 DIR *opendir_handle(int handle) 49 /** Like opendir_handle, but takes ownership of the handle if successful. */ 50 static DIR *opendir_internal(int handle) 55 51 { 56 52 DIR *dirp = malloc(sizeof(DIR)); … … 72 68 } 73 69 70 /** Open directory by its handle (a.k.a. file descriptor). 71 * 72 * @param handle Directory handle 73 * @return Non-NULL pointer on success. On error returns @c NULL and sets errno. 74 */ 75 DIR *opendir_handle(int handle) 76 { 77 int my_handle; 78 errno_t rc = vfs_clone(handle, -1, false, &my_handle); // Clone the file handle, otherwise closedir would put the 79 // handle that was passed to us here by the caller and that we don't own. 80 if (rc != EOK) { 81 errno = rc; 82 return NULL; 83 } 84 85 DIR *dirp = opendir_internal(my_handle); 86 rc = errno; 87 if (rc != EOK) { 88 vfs_put(my_handle); 89 errno = rc; 90 return NULL; 91 } 92 return dirp; 93 } 94 74 95 /** Open directory by its pathname. 75 96 * … … 87 108 } 88 109 89 DIR *dirp = opendir_ handle(fd);110 DIR *dirp = opendir_internal(fd); 90 111 rc = errno; 91 112 if (rc != EOK) { … … 97 118 } 98 119 99 /** Read directory entry.120 /** Read current directory entry and advance to the next one. 100 121 * 101 122 * @param dirp Open directory
Note:
See TracChangeset
for help on using the changeset viewer.
