Changeset e27cf669 in mainline for uspace/lib/libfs/libfs.c


Ignore:
Timestamp:
2010-02-09T20:19:23Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fb150d78
Parents:
975e7e9 (diff), eb73a50 (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 mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/libfs/libfs.c

    r975e7e9 re27cf669  
    161161        /* Accept the phone */
    162162        callid = async_get_call(&call);
    163         int mountee_phone = (int)IPC_GET_ARG1(call);
     163        int mountee_phone = (int) IPC_GET_ARG1(call);
    164164        if ((IPC_GET_METHOD(call) != IPC_M_CONNECTION_CLONE) ||
    165165            (mountee_phone < 0)) {
     
    172172        ipc_answer_0(callid, EOK);
    173173       
    174         res = async_data_write_receive(&callid, NULL);
    175         if (!res) {
    176                 ipc_hangup(mountee_phone);
    177                 ipc_answer_0(callid, EINVAL);
    178                 ipc_answer_0(rid, EINVAL);
    179                 return;
    180         }
    181        
    182174        fs_node_t *fn;
    183175        res = ops->node_get(&fn, mp_dev_handle, mp_fs_index);
    184176        if ((res != EOK) || (!fn)) {
    185177                ipc_hangup(mountee_phone);
    186                 ipc_answer_0(callid, combine_rc(res, ENOENT));
     178                async_data_write_void(combine_rc(res, ENOENT));
    187179                ipc_answer_0(rid, combine_rc(res, ENOENT));
    188180                return;
     
    192184                ipc_hangup(mountee_phone);
    193185                (void) ops->node_put(fn);
    194                 ipc_answer_0(callid, EBUSY);
     186                async_data_write_void(EBUSY);
    195187                ipc_answer_0(rid, EBUSY);
    196188                return;
     
    201193                ipc_hangup(mountee_phone);
    202194                (void) ops->node_put(fn);
    203                 ipc_answer_0(callid, rc);
     195                async_data_write_void(rc);
    204196                ipc_answer_0(rid, rc);
    205197                return;
     
    207199       
    208200        ipc_call_t answer;
    209         aid_t msg = async_send_1(mountee_phone, VFS_OUT_MOUNTED, mr_dev_handle,
    210             &answer);
    211         ipc_forward_fast(callid, mountee_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
    212         async_wait_for(msg, &rc);
     201        rc = async_data_write_forward_1_1(mountee_phone, VFS_OUT_MOUNTED,
     202            mr_dev_handle, &answer);
    213203       
    214204        if (rc == EOK) {
     
    224214        ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),
    225215            IPC_GET_ARG3(answer));
     216}
     217
     218void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *request)
     219{
     220        dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
     221        fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*request);
     222        fs_node_t *fn;
     223        int res;
     224
     225        res = ops->node_get(&fn, mp_dev_handle, mp_fs_index);
     226        if ((res != EOK) || (!fn)) {
     227                ipc_answer_0(rid, combine_rc(res, ENOENT));
     228                return;
     229        }
     230
     231        /*
     232         * We are clearly expecting to find the mount point active.
     233         */
     234        if (!fn->mp_data.mp_active) {
     235                (void) ops->node_put(fn);
     236                ipc_answer_0(rid, EINVAL);
     237                return;
     238        }
     239
     240        /*
     241         * Tell the mounted file system to unmount.
     242         */
     243        res = async_req_1_0(fn->mp_data.phone, VFS_OUT_UNMOUNTED,
     244            fn->mp_data.dev_handle);
     245
     246        /*
     247         * If everything went well, perform the clean-up on our side.
     248         */
     249        if (res == EOK) {
     250                ipc_hangup(fn->mp_data.phone);
     251                fn->mp_data.mp_active = false;
     252                fn->mp_data.fs_handle = 0;
     253                fn->mp_data.dev_handle = 0;
     254                fn->mp_data.phone = 0;
     255                /* Drop the reference created in libfs_mount(). */
     256                (void) ops->node_put(fn);
     257        }
     258
     259        (void) ops->node_put(fn);
     260        ipc_answer_0(rid, res);
    226261}
    227262
     
    304339                on_error(rc, goto out_with_answer);
    305340               
    306                 if ((tmp) && (tmp->mp_data.mp_active)) {
     341                /*
     342                 * If the matching component is a mount point, there are two
     343                 * legitimate semantics of the lookup operation. The first is
     344                 * the commonly used one in which the lookup crosses each mount
     345                 * point into the mounted file system. The second semantics is
     346                 * used mostly during unmount() and differs from the first one
     347                 * only in that the last mount point in the looked up path,
     348                 * which is also its last component, is not crossed.
     349                 */
     350
     351                if ((tmp) && (tmp->mp_data.mp_active) &&
     352                    (!(lflag & L_MP) || (next <= last))) {
    307353                        if (next > last)
    308354                                next = last = first;
     
    475521                goto out;
    476522        }
     523
     524        if ((lflag & L_ROOT) && par) {
     525                ipc_answer_0(rid, EINVAL);
     526                goto out;
     527        }
    477528       
    478529out_with_answer:
Note: See TracChangeset for help on using the changeset viewer.