Changeset 9c4cf0d in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2017-04-02T11:24:06Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
151f1cc
Parents:
b19e892
Message:

Rename close() to vfs_put()

This is motivated mainly by the fact that a file handle does not
necessarily correspond to an open file and close() was no longer the
the opposite operation to open().

Location:
uspace/app/bdsh/cmds/modules
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    rb19e892 r9c4cf0d  
    203203
    204204        if (NULL == (buff = (char *) malloc(blen + 1))) {
    205                 close(fd);
     205                vfs_put(fd);
    206206                printf("Unable to allocate enough memory to read %s\n",
    207207                    fname);
     
    213213
    214214                if (vfs_stat(fd, &st) != EOK) {
    215                         close(fd);
     215                        vfs_put(fd);
    216216                        free(buff);
    217217                        printf("Unable to vfs_stat %d\n", fd);
     
    287287        } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE));
    288288
    289         close(fd);
     289        vfs_put(fd);
    290290        if (bytes == -1) {
    291291                printf("Error reading %s\n", fname);
  • uspace/app/bdsh/cmds/modules/cmp/cmp.c

    rb19e892 r9c4cf0d  
    116116end:
    117117        if (fd[0] >= 0)
    118                 close(fd[0]);
     118                vfs_put(fd[0]);
    119119        if (fd[1] >= 0)
    120                 close(fd[1]);
     120                vfs_put(fd[1]);
    121121        return rc;
    122122}
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    rb19e892 r9c4cf0d  
    391391        if (fd2 < 0) {
    392392                printf("Unable to open destination file %s\n", dest);
    393                 close(fd1);
     393                vfs_put(fd1);
    394394                return -1;
    395395        }
     
    397397        if (vfs_stat(fd1, &st) != EOK) {
    398398                printf("Unable to fstat %d\n", fd1);
    399                 close(fd1);
    400                 close(fd2);
     399                vfs_put(fd1);
     400                vfs_put(fd2);
    401401                return -1;     
    402402        }
     
    425425
    426426out:
    427         close(fd1);
    428         close(fd2);
     427        vfs_put(fd1);
     428        vfs_put(fd2);
    429429        if (buff)
    430430                free(buff);
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    rb19e892 r9c4cf0d  
    168168                rc2 = write(fd, &pos, &byte, sizeof(char));
    169169                if (rc2 < 0) {
    170                         close(fd);
     170                        vfs_put(fd);
    171171                        goto error;
    172172                }
     
    186186                if (rc <= 0) {
    187187                        printf("%s: Error writing file (%d).\n", cmdname, errno);
    188                         close(fd);
     188                        vfs_put(fd);
    189189                        free(buffer);
    190190                        return CMD_FAILURE;
     
    195195        free(buffer);
    196196
    197         if (close(fd) < 0)
     197        if (vfs_put(fd) < 0)
    198198                goto error;
    199199
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    rb19e892 r9c4cf0d  
    152152        fd = vfs_lookup(path, WALK_REGULAR);
    153153        if (fd >= 0) {
    154                 close(fd);
     154                vfs_put(fd);
    155155                return RM_FILE;
    156156        }
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    rb19e892 r9c4cf0d  
    133133                        continue;
    134134                } else {
    135                         close(fd);
     135                        vfs_put(fd);
    136136                        fd = -1;
    137137                }
Note: See TracChangeset for help on using the changeset viewer.