Changeset 76a67ce in mainline


Ignore:
Timestamp:
2011-11-05T12:35:09Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4965357f
Parents:
10e4cd7
Message:

vfs_get_mtab:

  • Remove mtab entry when unmounting a filesystem
  • Add vfs_get_mtab() implementation
Location:
uspace/srv/vfs
Files:
3 edited

Legend:

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

    r10e4cd7 r76a67ce  
    128128                        break;
    129129                case VFS_IN_GET_MTAB:
    130                         //vfs_get_mounted_fs_info(callid, &call);
     130                        vfs_get_mtab(callid, &call);
    131131                        break;
    132132                default:
  • uspace/srv/vfs/vfs.h

    r10e4cd7 r76a67ce  
    220220extern void vfs_rename(ipc_callid_t, ipc_call_t *);
    221221extern void vfs_wait_handle(ipc_callid_t, ipc_call_t *);
     222extern void vfs_get_mtab(ipc_callid_t, ipc_call_t *);
    222223
    223224#endif
  • uspace/srv/vfs/vfs_ops.c

    r10e4cd7 r76a67ce  
    464464                 */
    465465               
    466                 free(mp);
    467                
    468466                exch = vfs_exchange_grab(mr_node->fs_handle);
    469467                rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED,
     
    473471                if (rc != EOK) {
    474472                        fibril_rwlock_write_unlock(&namespace_rwlock);
     473                        free(mp);
    475474                        vfs_node_put(mr_node);
    476475                        async_answer_0(rid, rc);
     
    490489               
    491490                rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL);
    492                 free(mp);
    493491                if (rc != EOK) {
    494492                        fibril_rwlock_write_unlock(&namespace_rwlock);
     493                        free(mp);
    495494                        vfs_node_put(mr_node);
    496495                        async_answer_0(rid, rc);
     
    501500                if (!mp_node) {
    502501                        fibril_rwlock_write_unlock(&namespace_rwlock);
     502                        free(mp);
    503503                        vfs_node_put(mr_node);
    504504                        async_answer_0(rid, ENOMEM);
     
    513513                if (rc != EOK) {
    514514                        fibril_rwlock_write_unlock(&namespace_rwlock);
     515                        free(mp);
    515516                        vfs_node_put(mp_node);
    516517                        vfs_node_put(mr_node);
     
    530531         */
    531532        vfs_node_forget(mr_node);
    532        
    533533        fibril_rwlock_write_unlock(&namespace_rwlock);
     534
     535        fibril_mutex_lock(&mtab_list_lock);
     536
     537        int found = 0;
     538
     539        list_foreach(mtab_list, cur) {
     540                mtab_list_ent_t *ent = list_get_instance(cur, mtab_list_ent_t,
     541                    link);
     542
     543                mtab_ent_t *mtab_ent = &ent->mtab_ent;
     544
     545                if (str_cmp(mtab_ent->mp, mp) == 0) {
     546                        list_remove(&ent->link);
     547                        mtab_size--;
     548                        free(ent);
     549                        found = 1;
     550                        break;
     551                }
     552        }
     553        assert(found);
     554
     555        free(mp);
     556
     557        fibril_mutex_unlock(&mtab_list_lock);
    534558        async_answer_0(rid, EOK);
    535559}
     
    13201344}
    13211345
     1346void vfs_get_mtab(ipc_callid_t rid, ipc_call_t *request)
     1347{
     1348        ipc_callid_t callid;
     1349        ipc_call_t data;
     1350        sysarg_t rc = EOK;
     1351        size_t len;
     1352
     1353        fibril_mutex_lock(&mtab_list_lock);
     1354
     1355        /* Send to the caller the number of mounted filesystems */
     1356        callid = async_get_call(&data);
     1357        if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {
     1358                rc = ENOTSUP;
     1359                async_answer_1(callid, rc, 0);
     1360                goto exit;
     1361        }
     1362        async_answer_1(callid, EOK, mtab_size);
     1363
     1364        list_foreach(mtab_list, cur) {
     1365                mtab_list_ent_t *ent = list_get_instance(cur, mtab_list_ent_t,
     1366                    link);
     1367
     1368                mtab_ent_t *mtab_ent = &ent->mtab_ent;
     1369
     1370                rc = ENOTSUP;
     1371
     1372                if (!async_data_read_receive(&callid, &len))
     1373                        goto exit;
     1374
     1375                (void) async_data_read_finalize(callid, mtab_ent->mp,
     1376                    str_size(mtab_ent->mp));
     1377
     1378                if (!async_data_read_receive(&callid, &len))
     1379                        goto exit;
     1380
     1381                (void) async_data_read_finalize(callid, mtab_ent->opts,
     1382                    str_size(mtab_ent->opts));
     1383
     1384                if (!async_data_read_receive(&callid, &len))
     1385                        goto exit;
     1386
     1387                (void) async_data_read_finalize(callid, mtab_ent->fs_name,
     1388                    str_size(mtab_ent->fs_name));
     1389
     1390                sysarg_t p[3];
     1391
     1392                p[0] = mtab_ent->flags;
     1393                p[1] = mtab_ent->instance;
     1394                p[2] = mtab_ent->fs_handle;
     1395
     1396                int i;
     1397                for (i = 0; i < 3; ++i) {
     1398                        callid = async_get_call(&data);
     1399                        if (IPC_GET_IMETHOD(data) != VFS_IN_PING) {
     1400                                rc = ENOTSUP;
     1401                                async_answer_1(callid, rc, 0);
     1402                                goto exit;
     1403                        }
     1404                        async_answer_1(callid, EOK, p[i]);
     1405                }
     1406
     1407                rc = EOK;
     1408        }
     1409
     1410exit:
     1411        fibril_mutex_unlock(&mtab_list_lock);
     1412        async_answer_0(rid, rc);
     1413}
     1414
    13221415/**
    13231416 * @}
Note: See TracChangeset for help on using the changeset viewer.