Changeset f49cf64 in mainline


Ignore:
Timestamp:
2009-06-29T16:03:18Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
057760d3
Parents:
7fcb74c
Message:

simplify init, create /dev/null0 on demand

File:
1 edited

Legend:

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

    r7fcb74c rf49cf64  
    5656static bool mount_root(const char *fstype)
    5757{
    58         int rc = -1;
    5958        char *opts = "";
    6059        const char *root_dev = "initrd";
     
    6261        if (str_cmp(fstype, "tmpfs") == 0)
    6362                opts = "restore";
    64 
    65         while (rc < 0) {
    66                 rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING);
    67                
    68                 switch (rc) {
    69                 case EOK:
    70                         printf(NAME ": Root filesystem mounted, %s at %s\n",
    71                             fstype, root_dev);
    72                         break;
    73                 case EBUSY:
    74                         printf(NAME ": Root filesystem already mounted\n");
    75                         break;
    76                 case ELIMIT:
    77                         printf(NAME ": Unable to mount root filesystem\n");
    78                         return false;
    79                 case ENOENT:
    80                         printf(NAME ": Unknown filesystem type (%s)\n", fstype);
    81                         return false;
    82                 }
     63       
     64        int rc = mount(fstype, "/", root_dev, opts, IPC_FLAG_BLOCKING);
     65       
     66        switch (rc) {
     67        case EOK:
     68                printf(NAME ": Root filesystem mounted, %s at %s\n",
     69                    fstype, root_dev);
     70                break;
     71        case EBUSY:
     72                printf(NAME ": Root filesystem already mounted\n");
     73                return false;
     74        case ELIMIT:
     75                printf(NAME ": Unable to mount root filesystem\n");
     76                return false;
     77        case ENOENT:
     78                printf(NAME ": Unknown filesystem type (%s)\n", fstype);
     79                return false;
     80        default:
     81                printf(NAME ": Error mounting root filesystem (%d)\n", rc);
     82                return false;
    8383        }
    8484       
     
    8888static bool mount_devfs(void)
    8989{
    90         int rc = -1;
    91        
    92         while (rc < 0) {
    93                 rc = mount("devfs", "/dev", "null", "", IPC_FLAG_BLOCKING);
    94                
    95                 switch (rc) {
    96                 case EOK:
    97                         printf(NAME ": Device filesystem mounted\n");
    98                         break;
    99                 case EBUSY:
    100                         printf(NAME ": Device filesystem already mounted\n");
    101                         break;
    102                 case ELIMIT:
    103                         printf(NAME ": Unable to mount device filesystem\n");
    104                         return false;
    105                 case ENOENT:
    106                         printf(NAME ": Unknown filesystem type (devfs)\n");
    107                         return false;
    108                 }
     90        char null[MAX_DEVICE_NAME];
     91        int null_id = devmap_null_create();
     92       
     93        if (null_id == -1) {
     94                printf(NAME ": Unable to create null device\n");
     95                return false;
     96        }
     97       
     98        snprintf(null, MAX_DEVICE_NAME, "null%d", null_id);
     99        int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING);
     100       
     101        switch (rc) {
     102        case EOK:
     103                printf(NAME ": Device filesystem mounted\n");
     104                break;
     105        case EBUSY:
     106                printf(NAME ": Device filesystem already mounted\n");
     107                devmap_null_destroy(null_id);
     108                return false;
     109        case ELIMIT:
     110                printf(NAME ": Unable to mount device filesystem\n");
     111                devmap_null_destroy(null_id);
     112                return false;
     113        case ENOENT:
     114                printf(NAME ": Unknown filesystem type (devfs)\n");
     115                devmap_null_destroy(null_id);
     116                return false;
     117        default:
     118                printf(NAME ": Error mounting device filesystem (%d)\n", rc);
     119                devmap_null_destroy(null_id);
     120                return false;
    109121        }
    110122       
     
    188200        spawn("/srv/ata_bd");
    189201        spawn("/srv/gxe_bd");
    190 
    191         usleep(250000);
    192         mount_data();   
    193 
     202       
     203        usleep(250000); // FIXME
     204        mount_data();
     205       
    194206        getvc("vc0", "/app/bdsh");
    195207        getvc("vc1", "/app/bdsh");
Note: See TracChangeset for help on using the changeset viewer.