Changes in uspace/srv/vfs/vfs_file.c [6639ae1:25bef0ff] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_file.c
r6639ae1 r25bef0ff 79 79 for (i = 0; i < MAX_OPEN_FILES; i++) { 80 80 if (FILES[i]) { 81 (void) vfs_close_internal(FILES[i]);82 81 (void) vfs_fd_free(i); 83 82 } … … 108 107 } 109 108 109 /** Close the file in the endpoint FS server. */ 110 static int vfs_file_close_remote(vfs_file_t *file) 111 { 112 ipc_call_t answer; 113 aid_t msg; 114 sysarg_t rc; 115 int phone; 116 117 assert(!file->refcnt); 118 119 phone = vfs_grab_phone(file->node->fs_handle); 120 msg = async_send_2(phone, VFS_OUT_CLOSE, file->node->devmap_handle, 121 file->node->index, &answer); 122 async_wait_for(msg, &rc); 123 vfs_release_phone(file->node->fs_handle, phone); 124 125 return IPC_GET_ARG1(answer); 126 } 127 128 110 129 /** Increment reference count of VFS file structure. 111 130 * … … 125 144 * decremented. 126 145 */ 127 static void vfs_file_delref(vfs_file_t *file) 128 { 146 static int vfs_file_delref(vfs_file_t *file) 147 { 148 int rc = EOK; 149 129 150 assert(fibril_mutex_is_locked(&VFS_DATA->lock)); 130 151 131 152 if (file->refcnt-- == 1) { 132 153 /* 133 * Lost the last reference to a file, need to drop our reference134 * to the underlying VFS node.154 * Lost the last reference to a file, need to close it in the 155 * endpoint FS and drop our reference to the underlying VFS node. 135 156 */ 157 rc = vfs_file_close_remote(file); 136 158 vfs_node_delref(file->node); 137 159 free(file); 138 160 } 161 162 return rc; 139 163 } 140 164 … … 201 225 int vfs_fd_free(int fd) 202 226 { 227 int rc; 228 203 229 if (!vfs_files_init()) 204 230 return ENOMEM; … … 210 236 } 211 237 212 vfs_file_delref(FILES[fd]);238 rc = vfs_file_delref(FILES[fd]); 213 239 FILES[fd] = NULL; 214 240 fibril_mutex_unlock(&VFS_DATA->lock); 215 241 216 return EOK;242 return rc; 217 243 } 218 244
Note:
See TracChangeset
for help on using the changeset viewer.