Changes in / [b067800:48cc66f] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 5 edited
-
app/cmpdirs/cmpdirs.c (deleted)
-
app/cmpdirs/meson.build (deleted)
-
app/meson.build (modified) (1 diff)
-
lib/c/generic/dirent.c (modified) (4 diffs)
-
lib/c/generic/vfs/vfs.c (modified) (1 diff)
-
lib/c/include/dirent.h (modified) (2 diffs)
-
srv/vfs/vfs_lookup.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/meson.build
rb067800 r48cc66f 35 35 'blkdump', 36 36 'calculator', 37 'cmpdirs',38 37 'copy', 39 38 'corecfg', -
uspace/lib/c/generic/dirent.c
rb067800 r48cc66f 1 1 /* 2 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2026 Vít Skalický4 3 * All rights reserved. 5 4 * … … 48 47 }; 49 48 50 /** Like opendir_handle, but takes ownership of the handle if successful. */ 51 static DIR *opendir_internal(int handle) 49 /** Open directory. 50 * 51 * @param dirname Directory pathname 52 * 53 * @return Non-NULL pointer on success. On error returns @c NULL and sets errno. 54 */ 55 DIR *opendir(const char *dirname) 52 56 { 53 57 DIR *dirp = malloc(sizeof(DIR)); … … 57 61 } 58 62 59 errno_t rc = vfs_open(handle, MODE_READ); 63 int fd; 64 errno_t rc = vfs_lookup(dirname, WALK_DIRECTORY, &fd); 60 65 if (rc != EOK) { 61 66 free(dirp); … … 64 69 } 65 70 66 dirp->fd = handle; 71 rc = vfs_open(fd, MODE_READ); 72 if (rc != EOK) { 73 free(dirp); 74 vfs_put(fd); 75 errno = rc; 76 return NULL; 77 } 78 79 dirp->fd = fd; 67 80 dirp->pos = 0; 68 81 return dirp; 69 82 } 70 83 71 /** Open directory by its handle (a.k.a. file descriptor). 72 * 73 * @param handle Directory handle 74 * @return Non-NULL pointer on success. On error returns @c NULL and sets errno. 75 */ 76 DIR *opendir_handle(int handle) 77 { 78 int my_handle; 79 // Clone the file handle, otherwise closedir would put the 80 // handle that was passed to us here by the caller and that we don't own. 81 errno_t rc = vfs_clone(handle, -1, false, &my_handle); 82 if (rc != EOK) { 83 errno = rc; 84 return NULL; 85 } 86 87 DIR *dirp = opendir_internal(my_handle); 88 if (!dirp) { 89 rc = errno; 90 vfs_put(my_handle); 91 errno = rc; 92 return NULL; 93 } 94 return dirp; 95 } 96 97 /** Open directory by its pathname. 98 * 99 * @param dirname Directory pathname 100 * 101 * @return Non-NULL pointer on success. On error returns @c NULL and sets errno. 102 */ 103 DIR *opendir(const char *dirname) 104 { 105 int fd; 106 errno_t rc = vfs_lookup(dirname, WALK_DIRECTORY, &fd); 107 if (rc != EOK) { 108 errno = rc; 109 return NULL; 110 } 111 112 DIR *dirp = opendir_internal(fd); 113 if (!dirp) { 114 rc = errno; 115 vfs_put(fd); 116 errno = rc; 117 return NULL; 118 } 119 return dirp; 120 } 121 122 /** Read current directory entry and advance to the next one. 84 /** Read directory entry. 123 85 * 124 86 * @param dirp Open directory -
uspace/lib/c/generic/vfs/vfs.c
rb067800 r48cc66f 1259 1259 * 1260 1260 * @param parent File handle of the parent node where the walk starts 1261 * @param path Parent-relative absolute path to be walked (an 1262 * absolute path with the parent being the root). 1263 * If /foo is parent and path is "/bar/baz", the 1264 * result would be /foo/bar/baz. Just "bar/baz" is 1265 * not valid. 1261 * @param path Parent-relative path to be walked 1266 1262 * @param flags Flags influencing the walk 1267 1263 * @param[out] handle File handle representing the result on success. -
uspace/lib/c/include/dirent.h
rb067800 r48cc66f 1 1 /* 2 2 * Copyright (c) 2008 Jakub Jermar 3 * Copyright (c) 2026 Vít Skalický4 3 * All rights reserved. 5 4 * … … 47 46 typedef struct __dirstream DIR; 48 47 49 extern DIR *opendir_handle(int handle);50 48 extern DIR *opendir(const char *); 51 49 extern struct dirent *readdir(DIR *); -
uspace/srv/vfs/vfs_lookup.c
rb067800 r48cc66f 325 325 * 326 326 * @param base The file from which to perform the lookup. 327 * @param path Path to be resolved; It must be an absolute path 328 * which get resolved relatively to base; it must be a 329 * NULL-terminated string. Example: If /foo is parent 330 * and path is "/bar/baz", the result would be /foo/bar/baz. 331 * Just "bar/baz" is not valid. 327 * @param path Path to be resolved; it must be a NULL-terminated 328 * string. 332 329 * @param lflag Flags to be used during lookup. 333 330 * @param result Empty structure where the lookup result will be stored.
Note:
See TracChangeset
for help on using the changeset viewer.
