Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset b7f9087 in mainline


Ignore:
Timestamp:
2008-07-07T13:07:11Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial
Children:
c98e6ee
Parents:
412a31e
Message:

Instead of aborting or crashing, return EBADF when an invalid file descriptor
is passed to vfs_close().

Location:
uspace/srv/vfs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs.h

    r412a31e rb7f9087  
    283283extern vfs_file_t *vfs_file_get(int);
    284284extern int vfs_fd_alloc(void);
    285 extern void vfs_fd_free(int);
     285extern int vfs_fd_free(int);
    286286
    287287extern void vfs_file_addref(vfs_file_t *);
  • uspace/srv/vfs/vfs_file.c

    r412a31e rb7f9087  
    9898 *
    9999 * @param fd            File descriptor being released.
     100 *
     101 * @return              EOK on success or EBADF if fd is an invalid file
     102 *                      descriptor.
    100103 */
    101 void vfs_fd_free(int fd)
     104int vfs_fd_free(int fd)
    102105{
    103         assert(fd < MAX_OPEN_FILES);
    104         assert(files[fd] != NULL);
     106        if ((fd >= MAX_OPEN_FILES) || (files[fd] == NULL))
     107                return EBADF;
    105108        vfs_file_delref(files[fd]);
    106109        files[fd] = NULL;
     110        return EOK;
    107111}
    108112
  • uspace/srv/vfs/vfs_ops.c

    r412a31e rb7f9087  
    375375{
    376376        int fd = IPC_GET_ARG1(*request);
    377         if (fd >= MAX_OPEN_FILES) {
    378                 ipc_answer_0(rid, EBADF);
    379                 return;
    380         }
    381         vfs_fd_free(fd);
    382         ipc_answer_0(rid, EOK);
     377        int rc = vfs_fd_free(fd);
     378        ipc_answer_0(rid, rc);
    383379}
    384380
Note: See TracChangeset for help on using the changeset viewer.