Changeset b33ec43 in mainline


Ignore:
Timestamp:
2011-08-18T12:10:23Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
27b76ca
Parents:
7171760
Message:

Remove support for directly opening nodes from VFS and libfs.

Location:
uspace
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/ipc/vfs.h

    r7171760 rb33ec43  
    6262typedef enum {
    6363        VFS_IN_OPEN = IPC_FIRST_USER_METHOD,
    64         VFS_IN_OPEN_NODE,
    6564        VFS_IN_READ,
    6665        VFS_IN_WRITE,
     
    8281
    8382typedef enum {
    84         VFS_OUT_OPEN_NODE = IPC_FIRST_USER_METHOD,
    85         VFS_OUT_READ,
     83        VFS_OUT_READ = IPC_FIRST_USER_METHOD,
    8684        VFS_OUT_WRITE,
    8785        VFS_OUT_TRUNCATE,
  • uspace/lib/fs/libfs.c

    r7171760 rb33ec43  
    7272    ipc_call_t *);
    7373static void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);
    74 static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,
    75     ipc_call_t *);
    7674
    7775static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req)
     
    198196}
    199197
    200 static void vfs_out_open_node(ipc_callid_t rid, ipc_call_t *req)
    201 {
    202         libfs_open_node(libfs_ops, reg.fs_handle, rid, req);
    203 }
    204 
    205198static void vfs_out_stat(ipc_callid_t rid, ipc_call_t *req)
    206199{
     
    267260                case VFS_OUT_DESTROY:
    268261                        vfs_out_destroy(callid, &call);
    269                         break;
    270                 case VFS_OUT_OPEN_NODE:
    271                         vfs_out_open_node(callid, &call);
    272262                        break;
    273263                case VFS_OUT_STAT:
     
    845835}
    846836
    847 /** Open VFS triplet.
    848  *
    849  * @param ops     libfs operations structure with function pointers to
    850  *                file system implementation
    851  * @param rid     Request ID of the VFS_OUT_OPEN_NODE request.
    852  * @param request VFS_OUT_OPEN_NODE request data itself.
    853  *
    854  */
    855 void libfs_open_node(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,
    856     ipc_call_t *request)
    857 {
    858         devmap_handle_t devmap_handle = IPC_GET_ARG1(*request);
    859         fs_index_t index = IPC_GET_ARG2(*request);
    860        
    861         fs_node_t *fn;
    862         int rc = ops->node_get(&fn, devmap_handle, index);
    863         on_error(rc, answer_and_return(rid, rc));
    864        
    865         if (fn == NULL) {
    866                 async_answer_0(rid, ENOENT);
    867                 return;
    868         }
    869        
    870         rc = ops->node_open(fn);
    871         aoff64_t size = ops->size_get(fn);
    872         async_answer_4(rid, rc, LOWER32(size), UPPER32(size),
    873             ops->lnkcnt_get(fn),
    874             (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
    875        
    876         (void) ops->node_put(fn);
    877 }
    878 
    879837/** @}
    880838 */
  • uspace/srv/vfs/vfs.c

    r7171760 rb33ec43  
    8383                        vfs_open(callid, &call);
    8484                        break;
    85                 case VFS_IN_OPEN_NODE:
    86                         vfs_open_node(callid, &call);
    87                         break;
    8885                case VFS_IN_CLOSE:
    8986                        vfs_close(callid, &call);
  • uspace/srv/vfs/vfs.h

    r7171760 rb33ec43  
    175175extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *,
    176176    vfs_pair_t *, ...);
    177 extern int vfs_open_node_internal(vfs_lookup_res_t *);
    178177
    179178extern bool vfs_nodes_init(void);
     
    204203extern void vfs_unmount(ipc_callid_t, ipc_call_t *);
    205204extern void vfs_open(ipc_callid_t, ipc_call_t *);
    206 extern void vfs_open_node(ipc_callid_t, ipc_call_t *);
    207205extern void vfs_sync(ipc_callid_t, ipc_call_t *);
    208206extern void vfs_dup(ipc_callid_t, ipc_call_t *);
  • uspace/srv/vfs/vfs_lookup.c

    r7171760 rb33ec43  
    201201}
    202202
    203 /** Perform a node open operation.
    204  *
    205  * @return EOK on success or an error code from errno.h.
    206  *
    207  */
    208 int vfs_open_node_internal(vfs_lookup_res_t *result)
    209 {
    210         async_exch_t *exch = vfs_exchange_grab(result->triplet.fs_handle);
    211        
    212         ipc_call_t answer;
    213         aid_t req = async_send_2(exch, VFS_OUT_OPEN_NODE,
    214             (sysarg_t) result->triplet.devmap_handle,
    215             (sysarg_t) result->triplet.index, &answer);
    216        
    217         sysarg_t rc;
    218         async_wait_for(req, &rc);
    219         vfs_exchange_release(exch);
    220        
    221         if (rc == EOK) {
    222                 result->size =
    223                     MERGE_LOUP32(IPC_GET_ARG1(answer), IPC_GET_ARG2(answer));
    224                 result->lnkcnt = (unsigned int) IPC_GET_ARG3(answer);
    225                 if (IPC_GET_ARG4(answer) & L_FILE)
    226                         result->type = VFS_NODE_FILE;
    227                 else if (IPC_GET_ARG4(answer) & L_DIRECTORY)
    228                         result->type = VFS_NODE_DIRECTORY;
    229                 else
    230                         result->type = VFS_NODE_UNKNOWN;
    231         }
    232        
    233         return rc;
    234 }
    235 
    236203/**
    237204 * @}
  • uspace/srv/vfs/vfs_ops.c

    r7171760 rb33ec43  
    618618}
    619619
    620 void vfs_open_node(ipc_callid_t rid, ipc_call_t *request)
    621 {
    622         // FIXME: check for sanity of the supplied fs, dev and index
    623        
    624         /*
    625          * The interface is open_node(fs, dev, index, oflag).
    626          */
    627         vfs_lookup_res_t lr;
    628        
    629         lr.triplet.fs_handle = IPC_GET_ARG1(*request);
    630         lr.triplet.devmap_handle = IPC_GET_ARG2(*request);
    631         lr.triplet.index = IPC_GET_ARG3(*request);
    632         int oflag = IPC_GET_ARG4(*request);
    633        
    634         fibril_rwlock_read_lock(&namespace_rwlock);
    635        
    636         int rc = vfs_open_node_internal(&lr);
    637         if (rc != EOK) {
    638                 fibril_rwlock_read_unlock(&namespace_rwlock);
    639                 async_answer_0(rid, rc);
    640                 return;
    641         }
    642        
    643         vfs_node_t *node = vfs_node_get(&lr);
    644         fibril_rwlock_read_unlock(&namespace_rwlock);
    645        
    646         /* Truncate the file if requested and if necessary. */
    647         if (oflag & O_TRUNC) {
    648                 fibril_rwlock_write_lock(&node->contents_rwlock);
    649                 if (node->size) {
    650                         rc = vfs_truncate_internal(node->fs_handle,
    651                             node->devmap_handle, node->index, 0);
    652                         if (rc) {
    653                                 fibril_rwlock_write_unlock(&node->contents_rwlock);
    654                                 vfs_node_put(node);
    655                                 async_answer_0(rid, rc);
    656                                 return;
    657                         }
    658                         node->size = 0;
    659                 }
    660                 fibril_rwlock_write_unlock(&node->contents_rwlock);
    661         }
    662        
    663         /*
    664          * Get ourselves a file descriptor and the corresponding vfs_file_t
    665          * structure.
    666          */
    667         int fd = vfs_fd_alloc((oflag & O_DESC) != 0);
    668         if (fd < 0) {
    669                 vfs_node_put(node);
    670                 async_answer_0(rid, fd);
    671                 return;
    672         }
    673         vfs_file_t *file = vfs_file_get(fd);
    674         file->node = node;
    675         if (oflag & O_APPEND)
    676                 file->append = true;
    677        
    678         /*
    679          * The following increase in reference count is for the fact that the
    680          * file is being opened and that a file structure is pointing to it.
    681          * It is necessary so that the file will not disappear when
    682          * vfs_node_put() is called. The reference will be dropped by the
    683          * respective VFS_IN_CLOSE.
    684          */
    685         vfs_node_addref(node);
    686         vfs_node_put(node);
    687         vfs_file_put(file);
    688        
    689         /* Success! Return the new file descriptor to the client. */
    690         async_answer_1(rid, EOK, fd);
    691 }
    692 
    693620void vfs_sync(ipc_callid_t rid, ipc_call_t *request)
    694621{
Note: See TracChangeset for help on using the changeset viewer.