Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/vfs/vfs_file.c

    r40feeac rb7fd2a0  
    6464} vfs_boxed_handle_t;
    6565
    66 static int _vfs_fd_free(vfs_client_data_t *, int);
     66static errno_t _vfs_fd_free(vfs_client_data_t *, int);
    6767
    6868/** Initialize the table of open files. */
     
    133133
    134134/** Close the file in the endpoint FS server. */
    135 static int vfs_file_close_remote(vfs_file_t *file)
     135static errno_t vfs_file_close_remote(vfs_file_t *file)
    136136{
    137137        assert(!file->refcnt);
     
    145145        vfs_exchange_release(exch);
    146146       
    147         sysarg_t rc;
     147        errno_t rc;
    148148        async_wait_for(msg, &rc);
    149149       
    150         return IPC_GET_ARG1(answer);
     150        return IPC_GET_RETVAL(answer);
    151151}
    152152
     
    168168 *                      decremented.
    169169 */
    170 static int vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file)
    171 {
    172         int rc = EOK;
     170static errno_t vfs_file_delref(vfs_client_data_t *vfs_data, vfs_file_t *file)
     171{
     172        errno_t rc = EOK;
    173173
    174174        assert(fibril_mutex_is_locked(&vfs_data->lock));
     
    192192}
    193193
    194 static int _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc)
     194static errno_t _vfs_fd_alloc(vfs_client_data_t *vfs_data, vfs_file_t **file, bool desc, int *out_fd)
    195195{
    196196        if (!vfs_files_init(vfs_data))
     
    223223                       
    224224                        fibril_mutex_unlock(&vfs_data->lock);
    225                         return (int) i;
     225                        *out_fd = (int) i;
     226                        return EOK;
    226227                }
    227228               
     
    249250 *             in a descending order.
    250251 *
    251  * @return First available file descriptor or a negative error
    252  *         code.
    253  */
    254 int vfs_fd_alloc(vfs_file_t **file, bool desc)
    255 {
    256         return _vfs_fd_alloc(VFS_DATA, file, desc);
    257 }
    258 
    259 static int _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd)
     252 * @param[out] out_fd  First available file descriptor
     253 *
     254 * @return Error code.
     255 */
     256errno_t vfs_fd_alloc(vfs_file_t **file, bool desc, int *out_fd)
     257{
     258        return _vfs_fd_alloc(VFS_DATA, file, desc, out_fd);
     259}
     260
     261static errno_t _vfs_fd_free_locked(vfs_client_data_t *vfs_data, int fd)
    260262{
    261263        if ((fd < 0) || (fd >= MAX_OPEN_FILES) || !vfs_data->files[fd]) {
     
    263265        }
    264266
    265         int rc = vfs_file_delref(vfs_data, vfs_data->files[fd]);
     267        errno_t rc = vfs_file_delref(vfs_data, vfs_data->files[fd]);
    266268        vfs_data->files[fd] = NULL;
    267269        return rc;
    268270}
    269271
    270 static int _vfs_fd_free(vfs_client_data_t *vfs_data, int fd)
    271 {
    272         int rc;
     272static errno_t _vfs_fd_free(vfs_client_data_t *vfs_data, int fd)
     273{
     274        errno_t rc;
    273275
    274276        if (!vfs_files_init(vfs_data))
     
    289291 *                      descriptor.
    290292 */
    291 int vfs_fd_free(int fd)
     293errno_t vfs_fd_free(int fd)
    292294{
    293295        return _vfs_fd_free(VFS_DATA, fd);
     
    303305 *
    304306 */
    305 int vfs_fd_assign(vfs_file_t *file, int fd)
     307errno_t vfs_fd_assign(vfs_file_t *file, int fd)
    306308{
    307309        if (!vfs_files_init(VFS_DATA))
     
    427429}
    428430
    429 int vfs_wait_handle_internal(bool high_fd)
     431errno_t vfs_wait_handle_internal(bool high_fd, int *out_fd)
    430432{
    431433        vfs_client_data_t *vfs_data = VFS_DATA;
     
    441443
    442444        vfs_file_t *file;
    443         int fd = _vfs_fd_alloc(vfs_data, &file, high_fd);
    444         if (fd < 0) {
     445        errno_t rc = _vfs_fd_alloc(vfs_data, &file, high_fd, out_fd);
     446        if (rc != EOK) {
    445447                vfs_node_delref(bh->node);
    446448                free(bh);
    447                 return fd;
     449                return rc;
    448450        }
    449451       
     
    452454        vfs_file_put(file);
    453455        free(bh);
    454         return fd;
     456        return EOK;
    455457}
    456458
Note: See TracChangeset for help on using the changeset viewer.