Changes in uspace/srv/vfs/vfs_file.c [40feeac:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_file.c
r40feeac rb7fd2a0 64 64 } vfs_boxed_handle_t; 65 65 66 static int _vfs_fd_free(vfs_client_data_t *, int);66 static errno_t _vfs_fd_free(vfs_client_data_t *, int); 67 67 68 68 /** Initialize the table of open files. */ … … 133 133 134 134 /** Close the file in the endpoint FS server. */ 135 static int vfs_file_close_remote(vfs_file_t *file)135 static errno_t vfs_file_close_remote(vfs_file_t *file) 136 136 { 137 137 assert(!file->refcnt); … … 145 145 vfs_exchange_release(exch); 146 146 147 sysarg_t rc;147 errno_t rc; 148 148 async_wait_for(msg, &rc); 149 149 150 return IPC_GET_ ARG1(answer);150 return IPC_GET_RETVAL(answer); 151 151 } 152 152 … … 168 168 * decremented. 169 169 */ 170 static int vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file)171 { 172 int rc = EOK;170 static errno_t vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file) 171 { 172 errno_t rc = EOK; 173 173 174 174 assert(fibril_mutex_is_locked(&vfs_data->lock)); … … 192 192 } 193 193 194 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc)194 static errno_t _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc, int *out_fd) 195 195 { 196 196 if (!vfs_files_init(vfs_data)) … … 223 223 224 224 fibril_mutex_unlock(&vfs_data->lock); 225 return (int) i; 225 *out_fd = (int) i; 226 return EOK; 226 227 } 227 228 … … 249 250 * in a descending order. 250 251 * 251 * @return First available file descriptor or a negative error 252 * code. 253 */ 254 int vfs_fd_alloc(vfs_file_t **file, bool desc) 255 { 256 return _vfs_fd_alloc(VFS_DATA, file, desc); 257 } 258 259 static int _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd) 252 * @param[out] out_fd First available file descriptor 253 * 254 * @return Error code. 255 */ 256 errno_t vfs_fd_alloc(vfs_file_t **file, bool desc, int *out_fd) 257 { 258 return _vfs_fd_alloc(VFS_DATA, file, desc, out_fd); 259 } 260 261 static errno_t _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd) 260 262 { 261 263 if ((fd < 0) || (fd >= MAX_OPEN_FILES) || !vfs_data->files[fd]) { … … 263 265 } 264 266 265 int rc = vfs_file_delref(vfs_data, vfs_data->files[fd]);267 errno_t rc = vfs_file_delref(vfs_data, vfs_data->files[fd]); 266 268 vfs_data->files[fd] = NULL; 267 269 return rc; 268 270 } 269 271 270 static int _vfs_fd_free(vfs_client_data_t *vfs_data, int fd)271 { 272 int rc;272 static errno_t _vfs_fd_free(vfs_client_data_t *vfs_data, int fd) 273 { 274 errno_t rc; 273 275 274 276 if (!vfs_files_init(vfs_data)) … … 289 291 * descriptor. 290 292 */ 291 int vfs_fd_free(int fd)293 errno_t vfs_fd_free(int fd) 292 294 { 293 295 return _vfs_fd_free(VFS_DATA, fd); … … 303 305 * 304 306 */ 305 int vfs_fd_assign(vfs_file_t *file, int fd)307 errno_t vfs_fd_assign(vfs_file_t *file, int fd) 306 308 { 307 309 if (!vfs_files_init(VFS_DATA)) … … 427 429 } 428 430 429 int vfs_wait_handle_internal(bool high_fd)431 errno_t vfs_wait_handle_internal(bool high_fd, int *out_fd) 430 432 { 431 433 vfs_client_data_t *vfs_data = VFS_DATA; … … 441 443 442 444 vfs_file_t *file; 443 int fd = _vfs_fd_alloc(vfs_data, &file, high_fd);444 if ( fd < 0) {445 errno_t rc = _vfs_fd_alloc(vfs_data, &file, high_fd, out_fd); 446 if (rc != EOK) { 445 447 vfs_node_delref(bh->node); 446 448 free(bh); 447 return fd;449 return rc; 448 450 } 449 451 … … 452 454 vfs_file_put(file); 453 455 free(bh); 454 return fd;456 return EOK; 455 457 } 456 458
Note:
See TracChangeset
for help on using the changeset viewer.