Changeset bf75e3cb in mainline for uspace/srv
- Timestamp:
- 2011-01-26T20:22:21Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e7d3dd, 5b7a107, 875c629
- Parents:
- a0ce870 (diff), 4fe94c66 (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. - Location:
- uspace/srv
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/clip/clip.c
ra0ce870 rbf75e3cb 183 183 async_set_client_connection(clip_connection); 184 184 185 sysarg_t phonead; 186 if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, &phonead) != 0) 185 if (ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, NULL, NULL)) 187 186 return -1; 188 187 -
uspace/srv/devman/main.c
ra0ce870 rbf75e3cb 586 586 587 587 /* Register device manager at naming service. */ 588 sysarg_t phonead; 589 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, &phonead) != 0) 588 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, NULL, NULL) != 0) 590 589 return -1; 591 590 -
uspace/srv/devmap/devmap.c
ra0ce870 rbf75e3cb 1150 1150 1151 1151 /* Register device mapper at naming service */ 1152 sysarg_t phonead; 1153 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) 1152 if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, NULL, NULL) != 0) 1154 1153 return -1; 1155 1154 -
uspace/srv/hid/adb_mouse/adb_dev.c
ra0ce870 rbf75e3cb 68 68 69 69 /* NB: The callback connection is slotted for removal */ 70 sysarg_t taskhash; 70 71 sysarg_t phonehash; 71 if (ipc_connect_to_me(dev_phone, 0, 0, 0, & phonehash) != 0) {72 if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) { 72 73 printf(NAME ": Failed to create callback from device\n"); 73 74 return false; 74 75 } 75 76 76 async_new_connection( phonehash, 0, NULL, adb_dev_events);77 async_new_connection(taskhash, phonehash, 0, NULL, adb_dev_events); 77 78 78 79 return 0; -
uspace/srv/hid/char_mouse/chardev.c
ra0ce870 rbf75e3cb 70 70 71 71 /* NB: The callback connection is slotted for removal */ 72 sysarg_t taskhash; 72 73 sysarg_t phonehash; 73 if (ipc_connect_to_me(dev_phone, 0, 0, 0, & phonehash) != 0) {74 if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) { 74 75 printf(NAME ": Failed to create callback from device\n"); 75 76 return false; 76 77 } 77 78 78 async_new_connection( phonehash, 0, NULL, chardev_events);79 async_new_connection(taskhash, phonehash, 0, NULL, chardev_events); 79 80 80 81 return 0; -
uspace/srv/hid/console/console.c
ra0ce870 rbf75e3cb 726 726 727 727 /* NB: The callback connection is slotted for removal */ 728 sysarg_t taskhash; 728 729 sysarg_t phonehash; 729 if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { 730 if (ipc_connect_to_me(kbd_phone, SERVICE_CONSOLE, 0, 0, &taskhash, 731 &phonehash) != 0) { 730 732 printf(NAME ": Failed to create callback from input device\n"); 731 733 return false; 732 734 } 733 735 734 async_new_connection( phonehash, 0, NULL, keyboard_events);736 async_new_connection(taskhash, phonehash, 0, NULL, keyboard_events); 735 737 736 738 /* Connect to mouse device */ … … 749 751 } 750 752 751 if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { 753 if (ipc_connect_to_me(mouse_phone, SERVICE_CONSOLE, 0, 0, &taskhash, 754 &phonehash) != 0) { 752 755 printf(NAME ": Failed to create callback from mouse device\n"); 753 756 mouse_phone = -1; … … 755 758 } 756 759 757 async_new_connection( phonehash, 0, NULL, mouse_events);760 async_new_connection(taskhash, phonehash, 0, NULL, mouse_events); 758 761 skip_mouse: 759 762 -
uspace/srv/hid/fb/main.c
ra0ce870 rbf75e3cb 114 114 return -1; 115 115 116 sysarg_t phonead; 117 if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0) 116 if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, NULL, NULL) != 0) 118 117 return -1; 119 118 -
uspace/srv/hid/kbd/port/adb.c
ra0ce870 rbf75e3cb 71 71 72 72 /* NB: The callback connection is slotted for removal */ 73 sysarg_t taskhash; 73 74 sysarg_t phonehash; 74 if (ipc_connect_to_me(dev_phone, 0, 0, 0, & phonehash) != 0) {75 if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) { 75 76 printf(NAME ": Failed to create callback from device\n"); 76 77 return false; 77 78 } 78 79 79 async_new_connection( phonehash, 0, NULL, kbd_port_events);80 async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events); 80 81 81 82 return 0; -
uspace/srv/hid/kbd/port/chardev.c
ra0ce870 rbf75e3cb 91 91 92 92 /* NB: The callback connection is slotted for removal */ 93 sysarg_t taskhash; 93 94 sysarg_t phonehash; 94 if (ipc_connect_to_me(dev_phone, 0, 0, 0, & phonehash) != 0) {95 if (ipc_connect_to_me(dev_phone, 0, 0, 0, &taskhash, &phonehash) != 0) { 95 96 printf(NAME ": Failed to create callback from device\n"); 96 97 return -1; 97 98 } 98 99 99 async_new_connection( phonehash, 0, NULL, kbd_port_events);100 async_new_connection(taskhash, phonehash, 0, NULL, kbd_port_events); 100 101 101 102 return 0; -
uspace/srv/hw/irc/apic/apic.c
ra0ce870 rbf75e3cb 108 108 109 109 async_set_client_connection(apic_connection); 110 sysarg_t phonead; 111 ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, &phonead); 110 ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, NULL, NULL); 112 111 113 112 return true; -
uspace/srv/hw/irc/fhc/fhc.c
ra0ce870 rbf75e3cb 137 137 138 138 async_set_client_connection(fhc_connection); 139 sysarg_t phonead; 140 ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, &phonead); 139 ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, NULL, NULL); 141 140 142 141 return true; -
uspace/srv/hw/irc/i8259/i8259.c
ra0ce870 rbf75e3cb 150 150 151 151 async_set_client_connection(i8259_connection); 152 sysarg_t phonead; 153 ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, &phonead); 152 ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, NULL, NULL); 154 153 155 154 return true; -
uspace/srv/hw/irc/obio/obio.c
ra0ce870 rbf75e3cb 138 138 139 139 async_set_client_connection(obio_connection); 140 sysarg_t phonead; 141 ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, &phonead); 140 ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, NULL, NULL); 142 141 143 142 return true; -
uspace/srv/hw/netif/ne2000/ne2000.c
ra0ce870 rbf75e3cb 397 397 async_set_interrupt_received(irq_handler); 398 398 399 sysarg_t phonehash; 400 return ipc_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, &phonehash); 399 return ipc_connect_to_me(PHONE_NS, SERVICE_NE2000, 0, 0, NULL, NULL); 401 400 } 402 401 -
uspace/srv/loader/main.c
ra0ce870 rbf75e3cb 423 423 int main(int argc, char *argv[]) 424 424 { 425 sysarg_t phonead;426 425 task_id_t id; 427 426 int rc; … … 439 438 440 439 /* Register at naming service. */ 441 if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)440 if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, NULL, NULL) != 0) 442 441 return -2; 443 442 -
uspace/srv/net/net/net.c
ra0ce870 rbf75e3cb 326 326 static int net_module_start(async_client_conn_t client_connection) 327 327 { 328 sysarg_t phonehash;329 328 int rc; 330 329 … … 338 337 goto out; 339 338 340 rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, &phonehash);339 rc = ipc_connect_to_me(PHONE_NS, SERVICE_NETWORKING, 0, 0, NULL, NULL); 341 340 if (rc != EOK) 342 341 goto out; -
uspace/srv/net/netif/lo/lo.c
ra0ce870 rbf75e3cb 167 167 int netif_initialize(void) 168 168 { 169 sysarg_t phonehash; 170 return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, &phonehash); 169 return ipc_connect_to_me(PHONE_NS, SERVICE_LO, 0, 0, NULL, NULL); 171 170 } 172 171 -
uspace/srv/vfs/vfs.c
ra0ce870 rbf75e3cb 59 59 ipc_answer_0(iid, EOK); 60 60 61 /*62 * Here we enter the main connection fibril loop.63 * The logic behind this loop and the protocol is that we'd like to keep64 * each connection open until the client hangs up. When the client hangs65 * up, we will free its VFS state. The act of hanging up the connection66 * by the client is equivalent to client termination because we cannot67 * distinguish one from the other. On the other hand, the client can68 * hang up arbitrarily if it has no open files and reestablish the69 * connection later.70 */71 61 while (keep_on_going) { 72 62 ipc_call_t call; … … 133 123 } 134 124 } 135 136 vfs_files_done(); 125 126 /* 127 * Open files for this client will be cleaned up when its last 128 * connection fibril terminates. 129 */ 137 130 } 138 131 … … 166 159 167 160 /* 161 * Set client data constructor and destructor. 162 */ 163 async_set_client_data_constructor(vfs_client_data_create); 164 async_set_client_data_destructor(vfs_client_data_destroy); 165 166 /* 168 167 * Set a connection handling function/fibril. 169 168 */ … … 173 172 * Register at the naming service. 174 173 */ 175 sysarg_t phonead; 176 ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead); 174 ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, NULL, NULL); 177 175 178 176 /* -
uspace/srv/vfs/vfs.h
ra0ce870 rbf75e3cb 188 188 #define MAX_OPEN_FILES 128 189 189 190 extern bool vfs_files_init(void); 191 extern void vfs_files_done(void); 190 extern void *vfs_client_data_create(void); 191 extern void vfs_client_data_destroy(void *); 192 192 193 extern vfs_file_t *vfs_file_get(int); 193 extern int vfs_fd_assign(vfs_file_t *file, int fd); 194 extern void vfs_file_put(vfs_file_t *); 195 extern int vfs_fd_assign(vfs_file_t *, int); 194 196 extern int vfs_fd_alloc(bool desc); 195 197 extern int vfs_fd_free(int); 196 197 extern void vfs_file_addref(vfs_file_t *);198 extern void vfs_file_delref(vfs_file_t *);199 198 200 199 extern void vfs_node_addref(vfs_node_t *); -
uspace/srv/vfs/vfs_file.c
ra0ce870 rbf75e3cb 45 45 #include "vfs.h" 46 46 47 /** 48 * This is a per-connection table of open files. 49 * Our assumption is that each client opens only one connection and therefore 50 * there is one table of open files per task. However, this may not be the case 51 * and the client can open more connections to VFS. In that case, there will be 52 * several tables and several file handle name spaces per task. Besides of this, 53 * the functionality will stay unchanged. So unless the client knows what it is 54 * doing, it should open one connection to VFS only. 55 * 56 * Allocation of the open files table is deferred until the client makes the 57 * first VFS_OPEN operation. 58 * 59 * This resource being per-connection and, in the first place, per-fibril, we 60 * don't need to protect it by a mutex. 61 */ 62 fibril_local vfs_file_t **files = NULL; 47 #define VFS_DATA ((vfs_client_data_t *) async_client_data_get()) 48 #define FILES (VFS_DATA->files) 49 50 typedef struct { 51 fibril_mutex_t lock; 52 vfs_file_t **files; 53 } vfs_client_data_t; 63 54 64 55 /** Initialize the table of open files. */ 65 bool vfs_files_init(void) 66 { 67 if (!files) { 68 files = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t *)); 69 if (!files) 56 static bool vfs_files_init(void) 57 { 58 fibril_mutex_lock(&VFS_DATA->lock); 59 if (!FILES) { 60 FILES = malloc(MAX_OPEN_FILES * sizeof(vfs_file_t *)); 61 if (!FILES) { 62 fibril_mutex_unlock(&VFS_DATA->lock); 70 63 return false; 71 memset(files, 0, MAX_OPEN_FILES * sizeof(vfs_file_t *)); 72 } 64 } 65 memset(FILES, 0, MAX_OPEN_FILES * sizeof(vfs_file_t *)); 66 } 67 fibril_mutex_unlock(&VFS_DATA->lock); 73 68 return true; 74 69 } 75 70 76 71 /** Cleanup the table of open files. */ 77 void vfs_files_done(void)72 static void vfs_files_done(void) 78 73 { 79 74 int i; 80 75 81 if (! files)76 if (!FILES) 82 77 return; 83 78 84 79 for (i = 0; i < MAX_OPEN_FILES; i++) { 85 if ( files[i]) {86 (void) vfs_close_internal( files[i]);80 if (FILES[i]) { 81 (void) vfs_close_internal(FILES[i]); 87 82 (void) vfs_fd_free(i); 88 83 } 89 84 } 90 85 91 free(files); 92 } 86 free(FILES); 87 } 88 89 void *vfs_client_data_create(void) 90 { 91 vfs_client_data_t *vfs_data; 92 93 vfs_data = malloc(sizeof(vfs_client_data_t)); 94 if (vfs_data) { 95 fibril_mutex_initialize(&vfs_data->lock); 96 vfs_data->files = NULL; 97 } 98 99 return vfs_data; 100 } 101 102 void vfs_client_data_destroy(void *data) 103 { 104 vfs_client_data_t *vfs_data = (vfs_client_data_t *) data; 105 106 vfs_files_done(); 107 free(vfs_data); 108 } 109 110 /** Increment reference count of VFS file structure. 111 * 112 * @param file File structure that will have reference count 113 * incremented. 114 */ 115 static void vfs_file_addref(vfs_file_t *file) 116 { 117 assert(fibril_mutex_is_locked(&VFS_DATA->lock)); 118 119 file->refcnt++; 120 } 121 122 /** Decrement reference count of VFS file structure. 123 * 124 * @param file File structure that will have reference count 125 * decremented. 126 */ 127 static void vfs_file_delref(vfs_file_t *file) 128 { 129 assert(fibril_mutex_is_locked(&VFS_DATA->lock)); 130 131 if (file->refcnt-- == 1) { 132 /* 133 * Lost the last reference to a file, need to drop our reference 134 * to the underlying VFS node. 135 */ 136 vfs_node_delref(file->node); 137 free(file); 138 } 139 } 140 93 141 94 142 /** Allocate a file descriptor. … … 111 159 i = 0; 112 160 161 fibril_mutex_lock(&VFS_DATA->lock); 113 162 while (true) { 114 if (!files[i]) { 115 files[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t)); 116 if (!files[i]) 163 if (!FILES[i]) { 164 FILES[i] = (vfs_file_t *) malloc(sizeof(vfs_file_t)); 165 if (!FILES[i]) { 166 fibril_mutex_unlock(&VFS_DATA->lock); 117 167 return ENOMEM; 168 } 118 169 119 memset(files[i], 0, sizeof(vfs_file_t)); 120 fibril_mutex_initialize(&files[i]->lock); 121 vfs_file_addref(files[i]); 170 memset(FILES[i], 0, sizeof(vfs_file_t)); 171 fibril_mutex_initialize(&FILES[i]->lock); 172 vfs_file_addref(FILES[i]); 173 fibril_mutex_unlock(&VFS_DATA->lock); 122 174 return (int) i; 123 175 } … … 135 187 } 136 188 } 189 fibril_mutex_unlock(&VFS_DATA->lock); 137 190 138 191 return EMFILE; … … 150 203 if (!vfs_files_init()) 151 204 return ENOMEM; 152 153 if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] == NULL)) 205 206 fibril_mutex_lock(&VFS_DATA->lock); 207 if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (FILES[fd] == NULL)) { 208 fibril_mutex_unlock(&VFS_DATA->lock); 154 209 return EBADF; 155 156 vfs_file_delref(files[fd]); 157 files[fd] = NULL; 210 } 211 212 vfs_file_delref(FILES[fd]); 213 FILES[fd] = NULL; 214 fibril_mutex_unlock(&VFS_DATA->lock); 158 215 159 216 return EOK; … … 173 230 if (!vfs_files_init()) 174 231 return ENOMEM; 175 176 if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (files[fd] != NULL)) 232 233 fibril_mutex_lock(&VFS_DATA->lock); 234 if ((fd < 0) || (fd >= MAX_OPEN_FILES) || (FILES[fd] != NULL)) { 235 fibril_mutex_unlock(&VFS_DATA->lock); 177 236 return EINVAL; 178 179 files[fd] = file; 180 vfs_file_addref(files[fd]); 237 } 238 239 FILES[fd] = file; 240 vfs_file_addref(FILES[fd]); 241 fibril_mutex_unlock(&VFS_DATA->lock); 181 242 182 243 return EOK; 183 244 } 184 245 185 /** Increment reference count of VFS file structure.186 *187 * @param file File structure that will have reference count188 * incremented.189 */190 void vfs_file_addref(vfs_file_t *file)191 {192 /*193 * File structures are per-connection, so no-one, except the current194 * fibril, should have a reference to them. This is the reason we don't195 * do any synchronization here.196 */197 file->refcnt++;198 }199 200 /** Decrement reference count of VFS file structure.201 *202 * @param file File structure that will have reference count203 * decremented.204 */205 void vfs_file_delref(vfs_file_t *file)206 {207 if (file->refcnt-- == 1) {208 /*209 * Lost the last reference to a file, need to drop our reference210 * to the underlying VFS node.211 */212 vfs_node_delref(file->node);213 free(file);214 }215 }216 217 246 /** Find VFS file structure for a given file descriptor. 218 247 * … … 226 255 return NULL; 227 256 228 if ((fd >= 0) && (fd < MAX_OPEN_FILES)) 229 return files[fd]; 257 fibril_mutex_lock(&VFS_DATA->lock); 258 if ((fd >= 0) && (fd < MAX_OPEN_FILES)) { 259 vfs_file_t *file = FILES[fd]; 260 vfs_file_addref(file); 261 fibril_mutex_unlock(&VFS_DATA->lock); 262 return file; 263 } 264 fibril_mutex_unlock(&VFS_DATA->lock); 230 265 231 266 return NULL; 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); 232 278 } 233 279 -
uspace/srv/vfs/vfs_ops.c
ra0ce870 rbf75e3cb 491 491 void vfs_open(ipc_callid_t rid, ipc_call_t *request) 492 492 { 493 if (!vfs_files_init()) {494 ipc_answer_0(rid, ENOMEM);495 return;496 }497 498 493 /* 499 494 * The POSIX interface is open(path, oflag, mode). … … 609 604 vfs_node_addref(node); 610 605 vfs_node_put(node); 606 vfs_file_put(file); 611 607 612 608 /* Success! Return the new file descriptor to the client. */ … … 617 613 { 618 614 // FIXME: check for sanity of the supplied fs, dev and index 619 620 if (!vfs_files_init()) {621 ipc_answer_0(rid, ENOMEM);622 return;623 }624 615 625 616 /* … … 686 677 vfs_node_addref(node); 687 678 vfs_node_put(node); 679 vfs_file_put(file); 688 680 689 681 /* Success! Return the new file descriptor to the client. */ … … 721 713 vfs_release_phone(file->node->fs_handle, fs_phone); 722 714 fibril_mutex_unlock(&file->lock); 723 715 716 vfs_file_put(file); 724 717 ipc_answer_0(rid, rc); 725 718 } … … 775 768 ipc_answer_0(rid, ret); 776 769 770 vfs_file_put(file); 777 771 ret = vfs_fd_free(fd); 778 772 ipc_answer_0(rid, ret); … … 875 869 file->pos += bytes; 876 870 fibril_mutex_unlock(&file->lock); 877 871 vfs_file_put(file); 872 878 873 /* 879 874 * FS server's reply is the final result of the whole operation we … … 915 910 file->pos = (aoff64_t) off; 916 911 fibril_mutex_unlock(&file->lock); 912 vfs_file_put(file); 917 913 ipc_answer_1(rid, EOK, off); 918 914 return; … … 922 918 if ((off >= 0) && (file->pos + off < file->pos)) { 923 919 fibril_mutex_unlock(&file->lock); 920 vfs_file_put(file); 924 921 ipc_answer_0(rid, EOVERFLOW); 925 922 return; … … 928 925 if ((off < 0) && (file->pos < (aoff64_t) -off)) { 929 926 fibril_mutex_unlock(&file->lock); 927 vfs_file_put(file); 930 928 ipc_answer_0(rid, EOVERFLOW); 931 929 return; … … 936 934 937 935 fibril_mutex_unlock(&file->lock); 936 vfs_file_put(file); 938 937 ipc_answer_2(rid, EOK, LOWER32(newoff), 939 938 UPPER32(newoff)); … … 946 945 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 947 946 fibril_mutex_unlock(&file->lock); 947 vfs_file_put(file); 948 948 ipc_answer_0(rid, EOVERFLOW); 949 949 return; … … 953 953 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 954 954 fibril_mutex_unlock(&file->lock); 955 vfs_file_put(file); 955 956 ipc_answer_0(rid, EOVERFLOW); 956 957 return; … … 962 963 fibril_rwlock_read_unlock(&file->node->contents_rwlock); 963 964 fibril_mutex_unlock(&file->lock); 965 vfs_file_put(file); 964 966 ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff)); 965 967 return; … … 967 969 968 970 fibril_mutex_unlock(&file->lock); 971 vfs_file_put(file); 969 972 ipc_answer_0(rid, EINVAL); 970 973 } … … 1005 1008 1006 1009 fibril_mutex_unlock(&file->lock); 1010 vfs_file_put(file); 1007 1011 ipc_answer_0(rid, (sysarg_t)rc); 1008 1012 } … … 1021 1025 ipc_callid_t callid; 1022 1026 if (!async_data_read_receive(&callid, NULL)) { 1027 vfs_file_put(file); 1023 1028 ipc_answer_0(callid, EINVAL); 1024 1029 ipc_answer_0(rid, EINVAL); … … 1038 1043 1039 1044 fibril_mutex_unlock(&file->lock); 1045 vfs_file_put(file); 1040 1046 ipc_answer_0(rid, rc); 1041 1047 } … … 1339 1345 int newfd = IPC_GET_ARG2(*request); 1340 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 1341 1353 /* Lookup the file structure corresponding to oldfd. */ 1342 1354 vfs_file_t *oldfile = vfs_file_get(oldfd); 1343 1355 if (!oldfile) { 1344 1356 ipc_answer_0(rid, EBADF); 1345 return;1346 }1347 1348 /* If the file descriptors are the same, do nothing. */1349 if (oldfd == newfd) {1350 ipc_answer_1(rid, EOK, newfd);1351 1357 return; 1352 1358 } … … 1365 1371 if (ret != EOK) { 1366 1372 fibril_mutex_unlock(&oldfile->lock); 1373 vfs_file_put(oldfile); 1374 vfs_file_put(newfile); 1367 1375 ipc_answer_0(rid, ret); 1368 1376 return; … … 1372 1380 if (ret != EOK) { 1373 1381 fibril_mutex_unlock(&oldfile->lock); 1382 vfs_file_put(oldfile); 1383 vfs_file_put(newfile); 1374 1384 ipc_answer_0(rid, ret); 1375 1385 return; 1376 1386 } 1387 vfs_file_put(newfile); 1377 1388 } 1378 1389 … … 1380 1391 int ret = vfs_fd_assign(oldfile, newfd); 1381 1392 fibril_mutex_unlock(&oldfile->lock); 1393 vfs_file_put(oldfile); 1382 1394 1383 1395 if (ret != EOK)
Note:
See TracChangeset
for help on using the changeset viewer.