Changeset bf75e3cb in mainline for uspace/srv/vfs/vfs_ops.c


Ignore:
Timestamp:
2011-01-26T20:22:21Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
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.
Message:

Merge from lp:~jakub/helenos/fs.

Highlights of the merge:

  • the kernel signs each call by the sender's task hash
  • async framework tracks and reference counts connections from the same client task
  • VFS associates the table of open files with the client task rather than with a single connection
  • VFS libc client code now uses async sessions to support parallel requests
  • vfs_file_get() now explicitly adds a reference on the file structure and the newly introduced vfs_file_put() drops it
File:
1 edited

Legend:

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

    ra0ce870 rbf75e3cb  
    491491void vfs_open(ipc_callid_t rid, ipc_call_t *request)
    492492{
    493         if (!vfs_files_init()) {
    494                 ipc_answer_0(rid, ENOMEM);
    495                 return;
    496         }
    497        
    498493        /*
    499494         * The POSIX interface is open(path, oflag, mode).
     
    609604        vfs_node_addref(node);
    610605        vfs_node_put(node);
     606        vfs_file_put(file);
    611607       
    612608        /* Success! Return the new file descriptor to the client. */
     
    617613{
    618614        // 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         }
    624615       
    625616        /*
     
    686677        vfs_node_addref(node);
    687678        vfs_node_put(node);
     679        vfs_file_put(file);
    688680       
    689681        /* Success! Return the new file descriptor to the client. */
     
    721713        vfs_release_phone(file->node->fs_handle, fs_phone);
    722714        fibril_mutex_unlock(&file->lock);
    723        
     715
     716        vfs_file_put(file);
    724717        ipc_answer_0(rid, rc);
    725718}
     
    775768                ipc_answer_0(rid, ret);
    776769       
     770        vfs_file_put(file);
    777771        ret = vfs_fd_free(fd);
    778772        ipc_answer_0(rid, ret);
     
    875869                file->pos += bytes;
    876870        fibril_mutex_unlock(&file->lock);
    877        
     871        vfs_file_put(file);     
     872
    878873        /*
    879874         * FS server's reply is the final result of the whole operation we
     
    915910                        file->pos = (aoff64_t) off;
    916911                        fibril_mutex_unlock(&file->lock);
     912                        vfs_file_put(file);
    917913                        ipc_answer_1(rid, EOK, off);
    918914                        return;
     
    922918                if ((off >= 0) && (file->pos + off < file->pos)) {
    923919                        fibril_mutex_unlock(&file->lock);
     920                        vfs_file_put(file);
    924921                        ipc_answer_0(rid, EOVERFLOW);
    925922                        return;
     
    928925                if ((off < 0) && (file->pos < (aoff64_t) -off)) {
    929926                        fibril_mutex_unlock(&file->lock);
     927                        vfs_file_put(file);
    930928                        ipc_answer_0(rid, EOVERFLOW);
    931929                        return;
     
    936934               
    937935                fibril_mutex_unlock(&file->lock);
     936                vfs_file_put(file);
    938937                ipc_answer_2(rid, EOK, LOWER32(newoff),
    939938                    UPPER32(newoff));
     
    946945                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    947946                        fibril_mutex_unlock(&file->lock);
     947                        vfs_file_put(file);
    948948                        ipc_answer_0(rid, EOVERFLOW);
    949949                        return;
     
    953953                        fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    954954                        fibril_mutex_unlock(&file->lock);
     955                        vfs_file_put(file);
    955956                        ipc_answer_0(rid, EOVERFLOW);
    956957                        return;
     
    962963                fibril_rwlock_read_unlock(&file->node->contents_rwlock);
    963964                fibril_mutex_unlock(&file->lock);
     965                vfs_file_put(file);
    964966                ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
    965967                return;
     
    967969       
    968970        fibril_mutex_unlock(&file->lock);
     971        vfs_file_put(file);
    969972        ipc_answer_0(rid, EINVAL);
    970973}
     
    10051008
    10061009        fibril_mutex_unlock(&file->lock);
     1010        vfs_file_put(file);
    10071011        ipc_answer_0(rid, (sysarg_t)rc);
    10081012}
     
    10211025        ipc_callid_t callid;
    10221026        if (!async_data_read_receive(&callid, NULL)) {
     1027                vfs_file_put(file);
    10231028                ipc_answer_0(callid, EINVAL);
    10241029                ipc_answer_0(rid, EINVAL);
     
    10381043
    10391044        fibril_mutex_unlock(&file->lock);
     1045        vfs_file_put(file);
    10401046        ipc_answer_0(rid, rc);
    10411047}
     
    13391345        int newfd = IPC_GET_ARG2(*request);
    13401346       
     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       
    13411353        /* Lookup the file structure corresponding to oldfd. */
    13421354        vfs_file_t *oldfile = vfs_file_get(oldfd);
    13431355        if (!oldfile) {
    13441356                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);
    13511357                return;
    13521358        }
     
    13651371                if (ret != EOK) {
    13661372                        fibril_mutex_unlock(&oldfile->lock);
     1373                        vfs_file_put(oldfile);
     1374                        vfs_file_put(newfile);
    13671375                        ipc_answer_0(rid, ret);
    13681376                        return;
     
    13721380                if (ret != EOK) {
    13731381                        fibril_mutex_unlock(&oldfile->lock);
     1382                        vfs_file_put(oldfile);
     1383                        vfs_file_put(newfile);
    13741384                        ipc_answer_0(rid, ret);
    13751385                        return;
    13761386                }
     1387                vfs_file_put(newfile);
    13771388        }
    13781389       
     
    13801391        int ret = vfs_fd_assign(oldfile, newfd);
    13811392        fibril_mutex_unlock(&oldfile->lock);
     1393        vfs_file_put(oldfile);
    13821394       
    13831395        if (ret != EOK)
Note: See TracChangeset for help on using the changeset viewer.