Changeset 41811af in mainline for uspace/srv/vfs/vfs_file.c
- Timestamp:
- 2011-06-10T10:14:26Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ab547063
- Parents:
- 9536e6e (diff), 390d80d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_file.c
r9536e6e r41811af 45 45 #include "vfs.h" 46 46 47 #define VFS_DATA ((vfs_client_data_t *) async_ client_data_get())47 #define VFS_DATA ((vfs_client_data_t *) async_get_client_data()) 48 48 #define FILES (VFS_DATA->files) 49 49 … … 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 assert(!file->refcnt); 113 114 async_exch_t *exch = vfs_exchange_grab(file->node->fs_handle); 115 116 ipc_call_t answer; 117 aid_t msg = async_send_2(exch, VFS_OUT_CLOSE, file->node->devmap_handle, 118 file->node->index, &answer); 119 120 vfs_exchange_release(exch); 121 122 sysarg_t rc; 123 async_wait_for(msg, &rc); 124 125 return IPC_GET_ARG1(answer); 126 } 127 110 128 /** Increment reference count of VFS file structure. 111 129 * … … 125 143 * decremented. 126 144 */ 127 static void vfs_file_delref(vfs_file_t *file) 128 { 145 static int vfs_file_delref(vfs_file_t *file) 146 { 147 int rc = EOK; 148 129 149 assert(fibril_mutex_is_locked(&VFS_DATA->lock)); 130 150 131 151 if (file->refcnt-- == 1) { 132 152 /* 133 * Lost the last reference to a file, need to drop our reference134 * to the underlying VFS node.153 * Lost the last reference to a file, need to close it in the 154 * endpoint FS and drop our reference to the underlying VFS node. 135 155 */ 156 rc = vfs_file_close_remote(file); 136 157 vfs_node_delref(file->node); 137 158 free(file); 138 159 } 160 161 return rc; 139 162 } 140 163 … … 201 224 int vfs_fd_free(int fd) 202 225 { 226 int rc; 227 203 228 if (!vfs_files_init()) 204 229 return ENOMEM; … … 210 235 } 211 236 212 vfs_file_delref(FILES[fd]);237 rc = vfs_file_delref(FILES[fd]); 213 238 FILES[fd] = NULL; 214 239 fibril_mutex_unlock(&VFS_DATA->lock); 215 240 216 return EOK;241 return rc; 217 242 } 218 243
Note:
See TracChangeset
for help on using the changeset viewer.