Changeset 6ad454f in mainline
- Timestamp:
- 2017-12-08T21:03:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a8c7a6d
- Parents:
- 9246016
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 06:01:16)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2017-12-08 21:03:35)
- Location:
- uspace/srv/vfs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.h
r9246016 r6ad454f 194 194 195 195 extern void vfs_op_pass_handle(task_id_t, task_id_t, int); 196 extern int vfs_wait_handle_internal(bool );196 extern int vfs_wait_handle_internal(bool, int *); 197 197 198 198 extern vfs_file_t *vfs_file_get(int); 199 199 extern void vfs_file_put(vfs_file_t *); 200 200 extern int vfs_fd_assign(vfs_file_t *, int); 201 extern int vfs_fd_alloc(vfs_file_t **file, bool desc );201 extern int vfs_fd_alloc(vfs_file_t **file, bool desc, int *); 202 202 extern int vfs_fd_free(int); 203 203 … … 220 220 extern int vfs_op_unlink(int parentfd, int expectfd, char *path); 221 221 extern int vfs_op_unmount(int mpfd); 222 extern int vfs_op_wait_handle(bool high_fd );222 extern int vfs_op_wait_handle(bool high_fd, int *out_fd); 223 223 extern int vfs_op_walk(int parentfd, int flags, char *path, int *out_fd); 224 224 extern int vfs_op_write(int fd, aoff64_t, size_t *out_bytes); -
uspace/srv/vfs/vfs_file.c
r9246016 r6ad454f 192 192 } 193 193 194 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc )194 static int _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); 252 * @param[out] out_fd First available file descriptor 253 * 254 * @return Error code. 255 */ 256 int vfs_fd_alloc(vfs_file_t **file, bool desc, int *out_fd) 257 { 258 return _vfs_fd_alloc(VFS_DATA, file, desc, out_fd); 257 259 } 258 260 … … 427 429 } 428 430 429 int vfs_wait_handle_internal(bool high_fd )431 int 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 int 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 -
uspace/srv/vfs/vfs_ipc.c
r9246016 r6ad454f 280 280 { 281 281 bool high_fd = IPC_GET_ARG1(*request); 282 int fd = vfs_op_wait_handle(high_fd); 283 async_answer_1(rid, EOK, fd); 282 int fd = -1; 283 int rc = vfs_op_wait_handle(high_fd, &fd); 284 async_answer_1(rid, rc, fd); 284 285 } 285 286 -
uspace/srv/vfs/vfs_ops.c
r9246016 r6ad454f 104 104 /* Assign the old file to newfd. */ 105 105 rc = vfs_fd_assign(oldfile, newfd); 106 *out_fd = newfd; 106 107 } else { 107 108 vfs_file_t *newfile; 108 int newfd = vfs_fd_alloc(&newfile, desc);109 if ( newfd >= 0) {109 rc = vfs_fd_alloc(&newfile, desc, out_fd); 110 if (rc == EOK) { 110 111 newfile->node = oldfile->node; 111 112 newfile->permissions = oldfile->permissions; … … 114 115 vfs_file_put(newfile); 115 116 } 116 rc = newfd;117 117 } 118 118 vfs_file_put(oldfile); 119 119 120 if (rc < 0) { 121 return rc; 122 } 123 124 *out_fd = rc; 125 return EOK; 120 return rc; 126 121 } 127 122 … … 228 223 229 224 int vfs_op_mount(int mpfd, unsigned service_id, unsigned flags, 230 unsigned instance, const char *opts, const char *fs_name, int *out fd)225 unsigned instance, const char *opts, const char *fs_name, int *out_fd) 231 226 { 232 227 int rc; 233 228 vfs_file_t *mp = NULL; 234 229 vfs_file_t *file = NULL; 235 intfd = -1;230 *out_fd = -1; 236 231 237 232 if (!(flags & VFS_MOUNT_CONNECT_ONLY)) { … … 259 254 260 255 if (!(flags & VFS_MOUNT_NO_REF)) { 261 fd = vfs_fd_alloc(&file, false); 262 if (fd < 0) { 263 rc = fd; 256 rc = vfs_fd_alloc(&file, false, out_fd); 257 if (rc != EOK) { 264 258 goto out; 265 259 } … … 300 294 vfs_file_put(file); 301 295 302 if (rc != EOK && fd >= 0) { 303 vfs_fd_free(fd); 304 fd = 0; 305 } 306 307 *outfd = fd; 296 if (rc != EOK && *out_fd >= 0) { 297 vfs_fd_free(*out_fd); 298 *out_fd = -1; 299 } 300 308 301 return rc; 309 302 } … … 833 826 } 834 827 835 int vfs_op_wait_handle(bool high_fd )836 { 837 return vfs_wait_handle_internal(high_fd );828 int vfs_op_wait_handle(bool high_fd, int *out_fd) 829 { 830 return vfs_wait_handle_internal(high_fd, out_fd); 838 831 } 839 832 … … 897 890 898 891 vfs_file_t *file; 899 int fd = vfs_fd_alloc(&file, false);900 if ( fd < 0) {892 rc = vfs_fd_alloc(&file, false, out_fd); 893 if (rc != EOK) { 901 894 vfs_node_put(node); 902 895 vfs_file_put(parent); 903 return fd;896 return rc; 904 897 } 905 898 assert(file != NULL); … … 915 908 fibril_rwlock_read_unlock(&namespace_rwlock); 916 909 917 *out_fd = fd;918 910 return EOK; 919 911 }
Note:
See TracChangeset
for help on using the changeset viewer.