Changeset 210e50a in mainline


Ignore:
Timestamp:
2010-02-03T13:36:46Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
28be7fa
Parents:
82474ef
Message:

understand an empty fqdn as the device argument to mount() as an implicit request to create a fresh null/%d device

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/init/init.c

    r82474ef r210e50a  
    9494static bool mount_devfs(void)
    9595{
    96         char null[MAX_DEVICE_NAME];
    97         int null_id = devmap_null_create();
    98        
    99         if (null_id == -1) {
    100                 printf(NAME ": Unable to create null device\n");
    101                 return false;
    102         }
    103        
    104         snprintf(null, MAX_DEVICE_NAME, "null/%d", null_id);
    105         int rc = mount("devfs", DEVFS_MOUNT_POINT, null, "", IPC_FLAG_BLOCKING);
     96        int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING);
    10697       
    10798        switch (rc) {
     
    111102        case EBUSY:
    112103                printf(NAME ": Device filesystem already mounted\n");
    113                 devmap_null_destroy(null_id);
    114104                return false;
    115105        case ELIMIT:
    116106                printf(NAME ": Unable to mount device filesystem\n");
    117                 devmap_null_destroy(null_id);
    118107                return false;
    119108        case ENOENT:
    120109                printf(NAME ": Unknown filesystem type (devfs)\n");
    121                 devmap_null_destroy(null_id);
    122110                return false;
    123111        default:
    124112                printf(NAME ": Error mounting device filesystem (%d)\n", rc);
    125                 devmap_null_destroy(null_id);
    126113                return false;
    127114        }
  • uspace/app/tester/vfs/vfs1.c

    r82474ef r210e50a  
    7979        TPRINTF("Created directory %s\n", MOUNT_POINT);
    8080       
    81         char null[MAX_DEVICE_NAME];
    82         int null_id = devmap_null_create();
    83        
    84         if (null_id == -1)
    85                 return "Unable to create null device";
    86        
    87         snprintf(null, MAX_DEVICE_NAME, "null/%d", null_id);
    88         int rc = mount(FS_TYPE, MOUNT_POINT, null, OPTIONS, FLAGS);
     81        int rc = mount(FS_TYPE, MOUNT_POINT, "", OPTIONS, FLAGS);
    8982        switch (rc) {
    9083        case EOK:
    91                 TPRINTF("Mounted /dev/%s as %s on %s\n", null, FS_TYPE, MOUNT_POINT);
     84                TPRINTF("Mounted %s on %s\n", FS_TYPE, MOUNT_POINT);
    9285                break;
    9386        case EBUSY:
  • uspace/lib/libc/generic/vfs/vfs.c

    r82474ef r210e50a  
    125125        aid_t req;
    126126        dev_handle_t dev_handle;
     127        int null_id = -1;
     128        char null[DEVMAP_NAME_MAXLEN];
     129       
     130        if (str_cmp(fqdn, "") == 0) {
     131                /* No device specified, create a fresh
     132                   null/%d device instead */
     133                null_id = devmap_null_create();
     134               
     135                if (null_id == -1)
     136                        return ENOMEM;
     137               
     138                snprintf(null, DEVMAP_NAME_MAXLEN, "null/%d", null_id);
     139                fqdn = null;
     140        }
    127141       
    128142        res = devmap_device_get_handle(fqdn, &dev_handle, flags);
    129         if (res != EOK)
     143        if (res != EOK) {
     144                if (null_id != -1)
     145                        devmap_null_destroy(null_id);
     146               
    130147                return res;
     148        }
    131149       
    132150        size_t mpa_size;
    133151        char *mpa = absolutize(mp, &mpa_size);
    134         if (!mpa)
    135                 return ENOMEM;
     152        if (!mpa) {
     153                if (null_id != -1)
     154                        devmap_null_destroy(null_id);
     155               
     156                return ENOMEM;
     157        }
    136158       
    137159        futex_down(&vfs_phone_futex);
     
    146168                futex_up(&vfs_phone_futex);
    147169                free(mpa);
     170               
     171                if (null_id != -1)
     172                        devmap_null_destroy(null_id);
     173               
    148174                if (rc_orig == EOK)
    149175                        return (int) rc;
     
    158184                futex_up(&vfs_phone_futex);
    159185                free(mpa);
    160                 if (rc_orig == EOK)
    161                         return (int) rc;
    162                 else
    163                         return (int) rc_orig;
    164         }
    165 
     186               
     187                if (null_id != -1)
     188                        devmap_null_destroy(null_id);
     189               
     190                if (rc_orig == EOK)
     191                        return (int) rc;
     192                else
     193                        return (int) rc_orig;
     194        }
     195       
    166196        rc = async_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
    167197        if (rc != EOK) {
     
    170200                futex_up(&vfs_phone_futex);
    171201                free(mpa);
    172                 if (rc_orig == EOK)
    173                         return (int) rc;
    174                 else
    175                         return (int) rc_orig;
    176         }
    177 
     202               
     203                if (null_id != -1)
     204                        devmap_null_destroy(null_id);
     205               
     206                if (rc_orig == EOK)
     207                        return (int) rc;
     208                else
     209                        return (int) rc_orig;
     210        }
     211       
    178212        /* Ask VFS whether it likes fs_name. */
    179213        rc = async_req_0_0(vfs_phone, IPC_M_PING);
     
    183217                futex_up(&vfs_phone_futex);
    184218                free(mpa);
     219               
     220                if (null_id != -1)
     221                        devmap_null_destroy(null_id);
     222               
    185223                if (rc_orig == EOK)
    186224                        return (int) rc;
     
    193231        futex_up(&vfs_phone_futex);
    194232        free(mpa);
     233       
     234        if ((rc != EOK) && (null_id != -1))
     235                devmap_null_destroy(null_id);
    195236       
    196237        return (int) rc;
Note: See TracChangeset for help on using the changeset viewer.