Changeset 9c4cf0d in mainline
- Timestamp:
- 2017-04-02T11:24:06Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 151f1cc
- Parents:
- b19e892
- Location:
- uspace
- Files:
-
- 36 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
rb19e892 r9c4cf0d 203 203 204 204 if (NULL == (buff = (char *) malloc(blen + 1))) { 205 close(fd);205 vfs_put(fd); 206 206 printf("Unable to allocate enough memory to read %s\n", 207 207 fname); … … 213 213 214 214 if (vfs_stat(fd, &st) != EOK) { 215 close(fd);215 vfs_put(fd); 216 216 free(buff); 217 217 printf("Unable to vfs_stat %d\n", fd); … … 287 287 } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 288 288 289 close(fd);289 vfs_put(fd); 290 290 if (bytes == -1) { 291 291 printf("Error reading %s\n", fname); -
uspace/app/bdsh/cmds/modules/cmp/cmp.c
rb19e892 r9c4cf0d 116 116 end: 117 117 if (fd[0] >= 0) 118 close(fd[0]);118 vfs_put(fd[0]); 119 119 if (fd[1] >= 0) 120 close(fd[1]);120 vfs_put(fd[1]); 121 121 return rc; 122 122 } -
uspace/app/bdsh/cmds/modules/cp/cp.c
rb19e892 r9c4cf0d 391 391 if (fd2 < 0) { 392 392 printf("Unable to open destination file %s\n", dest); 393 close(fd1);393 vfs_put(fd1); 394 394 return -1; 395 395 } … … 397 397 if (vfs_stat(fd1, &st) != EOK) { 398 398 printf("Unable to fstat %d\n", fd1); 399 close(fd1);400 close(fd2);399 vfs_put(fd1); 400 vfs_put(fd2); 401 401 return -1; 402 402 } … … 425 425 426 426 out: 427 close(fd1);428 close(fd2);427 vfs_put(fd1); 428 vfs_put(fd2); 429 429 if (buff) 430 430 free(buff); -
uspace/app/bdsh/cmds/modules/mkfile/mkfile.c
rb19e892 r9c4cf0d 168 168 rc2 = write(fd, &pos, &byte, sizeof(char)); 169 169 if (rc2 < 0) { 170 close(fd);170 vfs_put(fd); 171 171 goto error; 172 172 } … … 186 186 if (rc <= 0) { 187 187 printf("%s: Error writing file (%d).\n", cmdname, errno); 188 close(fd);188 vfs_put(fd); 189 189 free(buffer); 190 190 return CMD_FAILURE; … … 195 195 free(buffer); 196 196 197 if ( close(fd) < 0)197 if (vfs_put(fd) < 0) 198 198 goto error; 199 199 -
uspace/app/bdsh/cmds/modules/rm/rm.c
rb19e892 r9c4cf0d 152 152 fd = vfs_lookup(path, WALK_REGULAR); 153 153 if (fd >= 0) { 154 close(fd);154 vfs_put(fd); 155 155 return RM_FILE; 156 156 } -
uspace/app/bdsh/cmds/modules/touch/touch.c
rb19e892 r9c4cf0d 133 133 continue; 134 134 } else { 135 close(fd);135 vfs_put(fd); 136 136 fd = -1; 137 137 } -
uspace/app/bdsh/exec.c
rb19e892 r9c4cf0d 61 61 fd = vfs_lookup_open(f, WALK_REGULAR, MODE_READ); 62 62 if (fd >= 0) { 63 close(fd);63 vfs_put(fd); 64 64 return 0; 65 65 } else -
uspace/app/getterm/getterm.c
rb19e892 r9c4cf0d 74 74 return; 75 75 76 if ( close(oldfd))76 if (vfs_put(oldfd)) 77 77 return; 78 78 } -
uspace/app/redir/redir.c
rb19e892 r9c4cf0d 69 69 return; 70 70 71 if ( close(oldfd))71 if (vfs_put(oldfd)) 72 72 return; 73 73 } -
uspace/app/sysinst/futil.c
rb19e892 r9c4cf0d 83 83 } while (true); 84 84 85 (void) close(sf);85 (void) vfs_put(sf); 86 86 87 rc = close(df);87 rc = vfs_put(df); 88 88 if (rc < 0) 89 89 return EIO; … … 166 166 167 167 if (vfs_stat(sf, &st) != EOK) { 168 close(sf);168 vfs_put(sf); 169 169 return EIO; 170 170 } … … 174 174 data = calloc(fsize, 1); 175 175 if (data == NULL) { 176 close(sf);176 vfs_put(sf); 177 177 return ENOMEM; 178 178 } … … 180 180 nr = read(sf, (aoff64_t []) { 0 }, data, fsize); 181 181 if (nr != (ssize_t)fsize) { 182 close(sf);182 vfs_put(sf); 183 183 free(data); 184 184 return EIO; 185 185 } 186 186 187 (void) close(sf);187 (void) vfs_put(sf); 188 188 *rdata = data; 189 189 *rsize = fsize; -
uspace/app/taskdump/symtab.c
rb19e892 r9c4cf0d 165 165 166 166 free(shstrt); 167 close(fd);167 vfs_put(fd); 168 168 169 169 if (stab->sym == NULL || stab->strtab == NULL) { -
uspace/app/tester/hw/misc/virtchar1.c
rb19e892 r9c4cf0d 69 69 async_sess_t *sess = vfs_fd_session(fd, INTERFACE_DDF); 70 70 if (!sess) { 71 close(fd);71 vfs_put(fd); 72 72 TPRINTF(" ...error: %s\n", str_error(errno)); 73 73 return "Failed to get session to device"; … … 90 90 TPRINTF(" Closing session and file descriptor\n"); 91 91 async_hangup(sess); 92 close(fd);92 vfs_put(fd); 93 93 94 94 return NULL; -
uspace/app/tester/mm/pager1.c
rb19e892 r9c4cf0d 54 54 55 55 if (write(fd, (aoff64_t []) {0}, text, sizeof(text)) != sizeof(text)) { 56 close(fd);56 vfs_put(fd); 57 57 return NULL; 58 58 } … … 65 65 66 66 if (!vfs_pager_sess) { 67 close(fd);67 vfs_put(fd); 68 68 return NULL; 69 69 } … … 74 74 AS_AREA_READ | AS_AREA_CACHEABLE, vfs_pager_sess, fd, 0, 0); 75 75 if (result == AS_MAP_FAILED) { 76 close(fd);76 vfs_put(fd); 77 77 return NULL; 78 78 } … … 102 102 103 103 as_area_destroy(buffer); 104 close(fd);104 vfs_put(fd); 105 105 106 106 return NULL; -
uspace/app/tester/vfs/vfs1.c
rb19e892 r9c4cf0d 108 108 } 109 109 110 close(fd0);110 vfs_put(fd0); 111 111 112 112 const char *rv = read_root(); -
uspace/app/trace/trace.c
rb19e892 r9c4cf0d 531 531 if (fd_root >= 0) { 532 532 rc = loader_add_inbox(ldr, "root", fd_root); 533 close(fd_root);533 vfs_put(fd_root); 534 534 if (rc != EOK) 535 535 goto error; … … 705 705 o = oper_new("write", 3, arg_def, V_ERRNO, 1, resp_def); 706 706 proto_add_oper(p, VFS_IN_WRITE, o); 707 o = oper_new(" truncate", 5, arg_def, V_ERRNO, 0, resp_def);707 o = oper_new("vfs_resize", 5, arg_def, V_ERRNO, 0, resp_def); 708 708 proto_add_oper(p, VFS_IN_RESIZE, o); 709 o = oper_new(" fstat", 1, arg_def, V_ERRNO, 0, resp_def);709 o = oper_new("vfs_stat", 1, arg_def, V_ERRNO, 0, resp_def); 710 710 proto_add_oper(p, VFS_IN_STAT, o); 711 o = oper_new(" close", 1, arg_def, V_ERRNO, 0, resp_def);712 proto_add_oper(p, VFS_IN_ CLOSE, o);713 o = oper_new(" mount", 2, arg_def, V_ERRNO, 0, resp_def);711 o = oper_new("vfs_put", 1, arg_def, V_ERRNO, 0, resp_def); 712 proto_add_oper(p, VFS_IN_PUT, o); 713 o = oper_new("vfs_mount", 2, arg_def, V_ERRNO, 0, resp_def); 714 714 proto_add_oper(p, VFS_IN_MOUNT, o); 715 715 /* o = oper_new("unmount", 0, arg_def); 716 716 proto_add_oper(p, VFS_IN_UNMOUNT, o);*/ 717 o = oper_new(" sync", 1, arg_def, V_ERRNO, 0, resp_def);717 o = oper_new("vfs_sync", 1, arg_def, V_ERRNO, 0, resp_def); 718 718 proto_add_oper(p, VFS_IN_SYNC, o); 719 719 o = oper_new("rename", 0, arg_def, V_ERRNO, 0, resp_def); 720 720 proto_add_oper(p, VFS_IN_RENAME, o); 721 o = oper_new(" statfs", 0, arg_def, V_ERRNO, 0, resp_def);721 o = oper_new("vfs_statfs", 0, arg_def, V_ERRNO, 0, resp_def); 722 722 proto_add_oper(p, VFS_IN_STATFS, o); 723 o = oper_new(" walk", 2, arg_def, V_INT_ERRNO, 0, resp_def);723 o = oper_new("vfs_walk", 2, arg_def, V_INT_ERRNO, 0, resp_def); 724 724 proto_add_oper(p, VFS_IN_WALK, o); 725 o = oper_new(" open", 2, arg_def, V_ERRNO, 0, resp_def);725 o = oper_new("vfs_open", 2, arg_def, V_ERRNO, 0, resp_def); 726 726 proto_add_oper(p, VFS_IN_OPEN, o); 727 o = oper_new(" unlink", 3, arg_def, V_ERRNO, 0, resp_def);727 o = oper_new("vfs_unlink", 3, arg_def, V_ERRNO, 0, resp_def); 728 728 proto_add_oper(p, VFS_IN_UNLINK, o); 729 729 -
uspace/app/viewer/viewer.c
rb19e892 r9c4cf0d 116 116 int rc = vfs_stat(fd, &stat); 117 117 if (rc != EOK) { 118 close(fd);118 vfs_put(fd); 119 119 return false; 120 120 } … … 122 122 void *tga = malloc(stat.size); 123 123 if (tga == NULL) { 124 close(fd);124 vfs_put(fd); 125 125 return false; 126 126 } … … 129 129 if ((rd < 0) || (rd != (ssize_t) stat.size)) { 130 130 free(tga); 131 close(fd);132 return false; 133 } 134 135 close(fd);131 vfs_put(fd); 132 return false; 133 } 134 135 vfs_put(fd); 136 136 137 137 *p_local_surface = decode_tga(tga, stat.size, 0); -
uspace/app/websrv/websrv.c
rb19e892 r9c4cf0d 245 245 246 246 if (nr < 0) { 247 close(fd);247 vfs_put(fd); 248 248 return EIO; 249 249 } … … 252 252 if (rc != EOK) { 253 253 fprintf(stderr, "tcp_conn_send() failed\n"); 254 close(fd);254 vfs_put(fd); 255 255 return rc; 256 256 } 257 257 } 258 258 259 close(fd);259 vfs_put(fd); 260 260 261 261 return EOK; -
uspace/drv/bus/isa/isa.c
rb19e892 r9c4cf0d 298 298 299 299 if (opened) 300 close(fd);300 vfs_put(fd); 301 301 302 302 return buf; -
uspace/lib/bithenge/src/failure.c
rb19e892 r9c4cf0d 153 153 vfs_clone(null, STDOUT_FILENO, false); 154 154 vfs_clone(null, STDERR_FILENO, false); 155 close(null);155 vfs_put(null); 156 156 return 1; 157 157 } -
uspace/lib/bithenge/src/file.c
rb19e892 r9c4cf0d 88 88 { 89 89 file_blob_t *blob = blob_as_file(base); 90 close(blob->fd);90 vfs_put(blob->fd); 91 91 free(blob); 92 92 } … … 106 106 if (rc != EOK) { 107 107 if (needs_close) 108 close(fd);108 vfs_put(fd); 109 109 return rc; 110 110 } … … 114 114 if (!blob) { 115 115 if (needs_close) 116 close(fd);116 vfs_put(fd); 117 117 return ENOMEM; 118 118 } … … 121 121 free(blob); 122 122 if (needs_close) 123 close(fd);123 vfs_put(fd); 124 124 return rc; 125 125 } -
uspace/lib/c/generic/elf/elf_mod.c
rb19e892 r9c4cf0d 108 108 rc = elf_load_module(&elf, so_bias); 109 109 110 close(ofile);110 vfs_put(ofile); 111 111 return rc; 112 112 } … … 117 117 int file = vfs_lookup(path, 0); 118 118 int rc = elf_load_file(file, so_bias, flags, info); 119 close(file);119 vfs_put(file); 120 120 return rc; 121 121 } -
uspace/lib/c/generic/io/io.c
rb19e892 r9c4cf0d 305 305 if (rc != EOK) { 306 306 errno = rc; 307 close(file);307 vfs_put(file); 308 308 free(stream); 309 309 return NULL; … … 314 314 if (rc != EOK) { 315 315 errno = rc; 316 close(file);316 vfs_put(file); 317 317 free(stream); 318 318 return NULL; … … 370 370 371 371 if (stream->fd >= 0) 372 rc = close(stream->fd);372 rc = vfs_put(stream->fd); 373 373 374 374 list_remove(&stream->link); -
uspace/lib/c/generic/loader.c
rb19e892 r9c4cf0d 204 204 205 205 int rc = loader_set_program(ldr, name, fd); 206 close(fd);206 vfs_put(fd); 207 207 return rc; 208 208 } -
uspace/lib/c/generic/task.c
rb19e892 r9c4cf0d 181 181 if (root >= 0) { 182 182 rc = loader_add_inbox(ldr, "root", root); 183 close(root);183 vfs_put(root); 184 184 if (rc != EOK) 185 185 goto error; -
uspace/lib/c/generic/vfs/inbox.c
rb19e892 r9c4cf0d 1 1 2 2 #include <vfs/inbox.h> 3 #include <vfs/vfs.h> 3 4 4 5 #include <adt/list.h> … … 126 127 int original = inbox_set(entries[i].name, entries[i].file); 127 128 if (original >= 0) { 128 close(original);129 vfs_put(original); 129 130 } 130 131 } -
uspace/lib/c/generic/vfs/vfs.c
rb19e892 r9c4cf0d 82 82 fibril_mutex_lock(&root_mutex); 83 83 if (root_fd >= 0) 84 close(root_fd);84 vfs_put(root_fd); 85 85 root_fd = vfs_clone(nroot, -1, true); 86 86 fibril_mutex_unlock(&root_mutex); … … 149 149 } 150 150 int rc = _vfs_walk(root, p, flags); 151 close(root);151 vfs_put(root); 152 152 free(p); 153 153 return rc; … … 171 171 int rc = vfs_open(file, mode); 172 172 if (rc != EOK) { 173 close(file);173 vfs_put(file); 174 174 return rc; 175 175 } … … 342 342 rc = vfs_mount(mpfd, fs_name, service_id, opts, flags, 343 343 instance, NULL); 344 close(mpfd);344 vfs_put(mpfd); 345 345 } else { 346 346 rc = mpfd; … … 363 363 364 364 int rc = vfs_unmount(mp); 365 close(mp);365 vfs_put(mp); 366 366 return rc; 367 367 } … … 370 370 * 371 371 * @param fildes File descriptor 372 * @return Zero on success. On error -1 is returned and errno is set.373 */ 374 int close(int fildes)372 * @return EOK on success or a negative error code otherwise. 373 */ 374 int vfs_put(int fildes) 375 375 { 376 376 sysarg_t rc; 377 377 378 378 async_exch_t *exch = vfs_exchange_begin(); 379 rc = async_req_1_0(exch, VFS_IN_ CLOSE, fildes);379 rc = async_req_1_0(exch, VFS_IN_PUT, fildes); 380 380 vfs_exchange_end(exch); 381 381 … … 631 631 int rc = vfs_stat(file, stat); 632 632 633 close(file);633 vfs_put(file); 634 634 635 635 return rc; … … 660 660 if (rc < 0) { 661 661 free(dirp); 662 close(fd);662 vfs_put(fd); 663 663 errno = rc; 664 664 return NULL; … … 711 711 int rc; 712 712 713 rc = close(dirp->fd);713 rc = vfs_put(dirp->fd); 714 714 free(dirp); 715 715 … … 726 726 return file; 727 727 728 close(file);728 vfs_put(file); 729 729 730 730 return EOK; … … 762 762 763 763 free(pa); 764 close(parent);764 vfs_put(parent); 765 765 return rc; 766 766 } … … 816 816 if (parent < 0) { 817 817 free(pa); 818 close(expect);818 vfs_put(expect); 819 819 return parent; 820 820 } … … 823 823 824 824 free(pa); 825 close(parent);826 close(expect);825 vfs_put(parent); 826 vfs_put(expect); 827 827 return rc; 828 828 } … … 871 871 free(olda); 872 872 free(newa); 873 close(root);873 vfs_put(root); 874 874 async_wait_for(req, &rc_orig); 875 875 if (rc_orig != EOK) … … 886 886 free(olda); 887 887 free(newa); 888 close(root);888 vfs_put(root); 889 889 async_wait_for(req, &rc_orig); 890 890 if (rc_orig != EOK) … … 899 899 free(olda); 900 900 free(newa); 901 close(root);901 vfs_put(root); 902 902 async_wait_for(req, &rc); 903 903 … … 934 934 935 935 if (cwd_fd >= 0) 936 close(cwd_fd);936 vfs_put(cwd_fd); 937 937 938 938 if (cwd_path) … … 1124 1124 int rc = vfs_statfs(file, st); 1125 1125 1126 close(file);1126 vfs_put(file); 1127 1127 1128 1128 return rc; -
uspace/lib/c/include/ipc/vfs.h
rb19e892 r9c4cf0d 67 67 VFS_IN_RESIZE, 68 68 VFS_IN_STAT, 69 VFS_IN_CLOSE,70 69 VFS_IN_MOUNT, 70 VFS_IN_PUT, 71 71 VFS_IN_UNMOUNT, 72 72 VFS_IN_SYNC, -
uspace/lib/c/include/unistd.h
rb19e892 r9c4cf0d 61 61 extern ssize_t read(int, aoff64_t *, void *, size_t); 62 62 63 extern int close(int);64 65 63 extern char *getcwd(char *, size_t); 66 64 extern int chdir(const char *); -
uspace/lib/c/include/vfs/vfs.h
rb19e892 r9c4cf0d 97 97 unsigned, int *); 98 98 extern int vfs_open(int, int); 99 extern int vfs_put(int); 99 100 extern int vfs_resize(int, aoff64_t); 100 101 extern int vfs_root(void); -
uspace/lib/pcut/src/os/helenos.c
rb19e892 r9c4cf0d 218 218 219 219 leave_close_tempfile: 220 close(tempfile);220 vfs_put(tempfile); 221 221 vfs_unlink_path(tempfile_name); 222 222 -
uspace/lib/posix/source/fcntl.c
rb19e892 r9c4cf0d 142 142 rc = rcerrno(vfs_open, file, mode); 143 143 if (rc != EOK) { 144 close(file);144 vfs_put(file); 145 145 return -1; 146 146 } … … 150 150 rc = rcerrno(vfs_resize, file, 0); 151 151 if (rc != EOK) { 152 close(file);152 vfs_put(file); 153 153 return -1; 154 154 } -
uspace/lib/posix/source/unistd.c
rb19e892 r9c4cf0d 179 179 { 180 180 posix_pos[fildes] = 0; 181 return negerrno(close, fildes); 181 int rc = rcerrno(vfs_put, fildes); 182 if (rc != EOK) 183 return -1; 184 else 185 return 0; 182 186 } 183 187 … … 338 342 if (fd < 0) 339 343 return -1; 340 close(fd);344 posix_close(fd); 341 345 return 0; 342 346 } else { -
uspace/srv/devman/match.c
rb19e892 r9c4cf0d 243 243 244 244 if (opened) 245 close(fd);245 vfs_put(fd); 246 246 247 247 return suc; -
uspace/srv/vfs/vfs.h
rb19e892 r9c4cf0d 205 205 206 206 extern int vfs_op_clone(int oldfd, int newfd, bool desc); 207 extern int vfs_op_close(int fd);208 207 extern int vfs_op_mount(int mpfd, unsigned servid, unsigned flags, unsigned instance, const char *opts, const char *fsname, int *outfd); 209 208 extern int vfs_op_mtab_get(void); 210 209 extern int vfs_op_open(int fd, int flags); 210 extern int vfs_op_put(int fd); 211 211 extern int vfs_op_read(int fd, aoff64_t, size_t *out_bytes); 212 212 extern int vfs_op_rename(int basefd, char *old, char *new); -
uspace/srv/vfs/vfs_ipc.c
rb19e892 r9c4cf0d 44 44 } 45 45 46 static void vfs_in_close(ipc_callid_t rid, ipc_call_t *request)47 {48 int fd = IPC_GET_ARG1(*request);49 int rc = vfs_op_close(fd);50 async_answer_0(rid, rc);51 }52 53 46 static void vfs_in_mount(ipc_callid_t rid, ipc_call_t *request) 54 47 { … … 105 98 } 106 99 100 static void vfs_in_put(ipc_callid_t rid, ipc_call_t *request) 101 { 102 int fd = IPC_GET_ARG1(*request); 103 int rc = vfs_op_put(fd); 104 async_answer_0(rid, rc); 105 } 106 107 107 static void vfs_in_read(ipc_callid_t rid, ipc_call_t *request) 108 108 { … … 268 268 vfs_in_clone(callid, &call); 269 269 break; 270 case VFS_IN_CLOSE:271 vfs_in_close(callid, &call);272 break;273 270 case VFS_IN_MOUNT: 274 271 vfs_in_mount(callid, &call); … … 276 273 case VFS_IN_OPEN: 277 274 vfs_in_open(callid, &call); 275 break; 276 case VFS_IN_PUT: 277 vfs_in_put(callid, &call); 278 278 break; 279 279 case VFS_IN_READ: -
uspace/srv/vfs/vfs_ops.c
rb19e892 r9c4cf0d 124 124 } 125 125 126 int vfs_op_ close(int fd)126 int vfs_op_put(int fd) 127 127 { 128 128 return vfs_fd_free(fd);
Note:
See TracChangeset
for help on using the changeset viewer.