Changeset 4fe94c66 in mainline
- Timestamp:
- 2011-01-26T00:57:06Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 12573db, bf75e3cb
- Parents:
- 8b65e547
- Location:
- uspace/srv/vfs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.h
r8b65e547 r4fe94c66 192 192 193 193 extern vfs_file_t *vfs_file_get(int); 194 extern void vfs_file_put(vfs_file_t *); 194 195 extern int vfs_fd_assign(vfs_file_t *, int); 195 196 extern int vfs_fd_alloc(bool desc); -
uspace/srv/vfs/vfs_file.c
r8b65e547 r4fe94c66 258 258 if ((fd >= 0) && (fd < MAX_OPEN_FILES)) { 259 259 vfs_file_t *file = FILES[fd]; 260 vfs_file_addref(file); 260 261 fibril_mutex_unlock(&VFS_DATA->lock); 261 262 return file; … … 266 267 } 267 268 269 /** Stop using a file structure. 270 * 271 * @param file VFS file structure. 272 */ 273 void vfs_file_put(vfs_file_t *file) 274 { 275 fibril_mutex_lock(&VFS_DATA->lock); 276 vfs_file_delref(file); 277 fibril_mutex_unlock(&VFS_DATA->lock); 278 } 279 268 280 /** 269 281 * @} -
uspace/srv/vfs/vfs_ops.c
r8b65e547 r4fe94c66 604 604 vfs_node_addref(node); 605 605 vfs_node_put(node); 606 vfs_file_put(file); 606 607 607 608 /* Success! Return the new file descriptor to the client. */ … … 676 677 vfs_node_addref(node); 677 678 vfs_node_put(node); 679 vfs_file_put(file); 678 680 679 681 /* Success! Return the new file descriptor to the client. */ … … 711 713 vfs_release_phone(file->node->fs_handle, fs_phone); 712 714 fibril_mutex_unlock(&file->lock); 713 715 716 vfs_file_put(file); 714 717 ipc_answer_0(rid, rc); 715 718 } … … 765 768 ipc_answer_0(rid, ret); 766 769 770 vfs_file_put(file); 767 771 ret = vfs_fd_free(fd); 768 772 ipc_answer_0(rid, ret); … … 865 869 file->pos += bytes; 866 870 fibril_mutex_unlock(&file->lock); 867 871 vfs_file_put(file); 872 868 873 /* 869 874 * FS server's reply is the final result of the whole operation we … … 905 910 file->pos = (aoff64_t) off; 906 911 fibril_mutex_unlock(&file->lock); 912 vfs_file_put(file); 907 913 ipc_answer_1(rid, EOK, off); 908 914 return; … … 912 918 if ((off >= 0) && (file->pos + off < file->pos)) { 913 919 fibril_mutex_unlock(&file->lock); 920 vfs_file_put(file); 914 921 ipc_answer_0(rid, EOVERFLOW); 915 922 return; … … 918 925 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 919 926 fibril_mutex_unlock(&file->lock); 927 vfs_file_put(file); 920 928 ipc_answer_0(rid, EOVERFLOW); 921 929 return; … … 926 934 927 935 fibril_mutex_unlock(&file->lock); 936 vfs_file_put(file); 928 937 ipc_answer_2(rid, EOK, LOWER32(newoff), 929 938 UPPER32(newoff)); … … 936 945 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 937 946 fibril_mutex_unlock(&file->lock); 947 vfs_file_put(file); 938 948 ipc_answer_0(rid, EOVERFLOW); 939 949 return; … … 943 953 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 944 954 fibril_mutex_unlock(&file->lock); 955 vfs_file_put(file); 945 956 ipc_answer_0(rid, EOVERFLOW); 946 957 return; … … 952 963 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 953 964 fibril_mutex_unlock(&file->lock); 965 vfs_file_put(file); 954 966 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 955 967 return; … … 957 969 958 970 fibril_mutex_unlock(&file->lock); 971 vfs_file_put(file); 959 972 ipc_answer_0(rid, EINVAL); 960 973 } … … 995 1008 996 1009 fibril_mutex_unlock(&file->lock); 1010 vfs_file_put(file); 997 1011 ipc_answer_0(rid, (sysarg_t)rc); 998 1012 } … … 1011 1025 ipc_callid_t callid; 1012 1026 if (!async_data_read_receive(&callid, NULL)) { 1027 vfs_file_put(file); 1013 1028 ipc_answer_0(callid, EINVAL); 1014 1029 ipc_answer_0(rid, EINVAL); … … 1028 1043 1029 1044 fibril_mutex_unlock(&file->lock); 1045 vfs_file_put(file); 1030 1046 ipc_answer_0(rid, rc); 1031 1047 } … … 1329 1345 int newfd = IPC_GET_ARG2(*request); 1330 1346 1347 /* If the file descriptors are the same, do nothing. */ 1348 if (oldfd == newfd) { 1349 ipc_answer_1(rid, EOK, newfd); 1350 return; 1351 } 1352 1331 1353 /* Lookup the file structure corresponding to oldfd. */ 1332 1354 vfs_file_t *oldfile = vfs_file_get(oldfd); 1333 1355 if (!oldfile) { 1334 1356 ipc_answer_0(rid, EBADF); 1335 return;1336 }1337 1338 /* If the file descriptors are the same, do nothing. */1339 if (oldfd == newfd) {1340 ipc_answer_1(rid, EOK, newfd);1341 1357 return; 1342 1358 } … … 1355 1371 if (ret != EOK) { 1356 1372 fibril_mutex_unlock(&oldfile->lock); 1373 vfs_file_put(oldfile); 1374 vfs_file_put(newfile); 1357 1375 ipc_answer_0(rid, ret); 1358 1376 return; … … 1362 1380 if (ret != EOK) { 1363 1381 fibril_mutex_unlock(&oldfile->lock); 1382 vfs_file_put(oldfile); 1383 vfs_file_put(newfile); 1364 1384 ipc_answer_0(rid, ret); 1365 1385 return; 1366 1386 } 1387 vfs_file_put(newfile); 1367 1388 } 1368 1389 … … 1370 1391 int ret = vfs_fd_assign(oldfile, newfd); 1371 1392 fibril_mutex_unlock(&oldfile->lock); 1393 vfs_file_put(oldfile); 1372 1394 1373 1395 if (ret != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.