Changes in uspace/app/init/init.c [28be7fa:5ebdf94] in mainline


Ignore:
File:
1 edited

Legend:

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

    r28be7fa r5ebdf94  
    5050#include "init.h"
    5151
    52 #define DEVFS_MOUNT_POINT  "/dev"
    53 
    54 #define SRV_CONSOLE  "/srv/console"
    55 #define APP_GETTERM  "/app/getterm"
    56 
    5752static void info_print(void)
    5853{
     
    6358{
    6459        char *opts = "";
    65         const char *root_dev = "bd/initrd";
     60        const char *root_dev = "initrd";
    6661       
    6762        if (str_cmp(fstype, "tmpfs") == 0)
     
    9489static bool mount_devfs(void)
    9590{
    96         int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING);
     91        char null[MAX_DEVICE_NAME];
     92        int null_id = devmap_null_create();
     93       
     94        if (null_id == -1) {
     95                printf(NAME ": Unable to create null device\n");
     96                return false;
     97        }
     98       
     99        snprintf(null, MAX_DEVICE_NAME, "null%d", null_id);
     100        int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING);
    97101       
    98102        switch (rc) {
     
    102106        case EBUSY:
    103107                printf(NAME ": Device filesystem already mounted\n");
     108                devmap_null_destroy(null_id);
    104109                return false;
    105110        case ELIMIT:
    106111                printf(NAME ": Unable to mount device filesystem\n");
     112                devmap_null_destroy(null_id);
    107113                return false;
    108114        case ENOENT:
    109115                printf(NAME ": Unknown filesystem type (devfs)\n");
     116                devmap_null_destroy(null_id);
    110117                return false;
    111118        default:
    112119                printf(NAME ": Error mounting device filesystem (%d)\n", rc);
     120                devmap_null_destroy(null_id);
    113121                return false;
    114122        }
     
    162170        }
    163171
    164         if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) {
     172        if (texit != TASK_EXIT_NORMAL || retval != 0) {
    165173                printf(NAME ": Server %s failed to start (returned %d)\n",
    166174                        fname, retval);
     
    168176}
    169177
    170 static void console(char *dev)
    171 {
    172         char *argv[3];
    173         char hid_in[DEVMAP_NAME_MAXLEN];
     178static void getvc(char *dev, char *app)
     179{
     180        char *argv[4];
     181        char vc[MAX_DEVICE_NAME];
    174182        int rc;
    175183       
    176         snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev);
    177        
    178         printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in);
    179        
    180         /* Wait for the input device to be ready */
     184        snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev);
     185       
     186        printf(NAME ": Spawning getvc on %s\n", vc);
     187       
    181188        dev_handle_t handle;
    182189        rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
    183190       
    184191        if (rc == EOK) {
    185                 argv[0] = SRV_CONSOLE;
    186                 argv[1] = hid_in;
    187                 argv[2] = NULL;
    188                
    189                 if (!task_spawn(SRV_CONSOLE, argv))
    190                         printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in);
    191         } else
    192                 printf(NAME ": Error waiting on %s\n", hid_in);
    193 }
    194 
    195 static void getterm(char *dev, char *app)
    196 {
    197         char *argv[4];
    198         char term[DEVMAP_NAME_MAXLEN];
    199         int rc;
    200        
    201         snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev);
    202        
    203         printf(NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app);
    204        
    205         /* Wait for the terminal device to be ready */
    206         dev_handle_t handle;
    207         rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING);
    208        
    209         if (rc == EOK) {
    210                 argv[0] = APP_GETTERM;
    211                 argv[1] = term;
     192                argv[0] = "/app/getvc";
     193                argv[1] = vc;
    212194                argv[2] = app;
    213195                argv[3] = NULL;
    214196               
    215                 if (!task_spawn(APP_GETTERM, argv))
    216                         printf(NAME ": Error spawning %s with %s %s\n", APP_GETTERM,
    217                             term, app);
    218         } else
    219                 printf(NAME ": Error waiting on %s\n", term);
    220 }
    221 
    222 static void mount_scratch(void)
     197                if (!task_spawn("/app/getvc", argv))
     198                        printf(NAME ": Error spawning getvc on %s\n", vc);
     199        } else {
     200                printf(NAME ": Error waiting on %s\n", vc);
     201        }
     202}
     203
     204static void mount_data(void)
    223205{
    224206        int rc;
    225207
    226         printf("Trying to mount null/0 on /scratch... ");
     208        printf("Trying to mount disk0 on /data... ");
    227209        fflush(stdout);
    228210
    229         rc = mount("tmpfs", "/scratch", "null/0", "", 0);
     211        rc = mount("fat", "/data", "disk0", "wtcache", 0);
    230212        if (rc == EOK)
    231213                printf("OK\n");
     
    234216}
    235217
    236 static void mount_data(void)
    237 {
    238         int rc;
    239 
    240         printf("Trying to mount bd/disk0 on /data... ");
    241         fflush(stdout);
    242 
    243         rc = mount("fat", "/data", "bd/disk0", "wtcache", 0);
    244         if (rc == EOK)
    245                 printf("OK\n");
    246         else
    247                 printf("Failed\n");
    248 }
    249 
    250218int main(int argc, char *argv[])
    251219{
     
    256224                return -1;
    257225        }
    258 
    259         /* Make sure tmpfs is running. */
    260         if (str_cmp(STRING(RDFMT), "tmpfs") != 0) {
    261                 spawn("/srv/tmpfs");
    262         }
    263226       
    264227        spawn("/srv/devfs");
    265         spawn("/srv/taskmon");
    266228       
    267229        if (!mount_devfs()) {
     
    269231                return -2;
    270232        }
    271 
    272         mount_scratch();
    273        
     233       
     234        spawn("/srv/fb");
     235        spawn("/srv/kbd");
     236        spawn("/srv/console");
    274237        spawn("/srv/fhc");
    275238        spawn("/srv/obio");
    276         srv_start("/srv/cuda_adb");
    277         srv_start("/srv/i8042");
    278         srv_start("/srv/adb_ms");
    279         srv_start("/srv/char_ms");
    280 
    281         spawn("/srv/fb");
    282         spawn("/srv/kbd");
    283         console("hid_in/kbd");
    284        
    285         spawn("/srv/clip");
    286239
    287240        /*
     
    302255#endif
    303256
    304         getterm("term/vc0", "/app/bdsh");
    305         getterm("term/vc1", "/app/bdsh");
    306         getterm("term/vc2", "/app/bdsh");
    307         getterm("term/vc3", "/app/bdsh");
    308         getterm("term/vc4", "/app/bdsh");
    309         getterm("term/vc5", "/app/bdsh");
    310         getterm("term/vc6", "/app/klog");
    311 
     257        getvc("vc0", "/app/bdsh");
     258        getvc("vc1", "/app/bdsh");
     259        getvc("vc2", "/app/bdsh");
     260        getvc("vc3", "/app/bdsh");
     261        getvc("vc4", "/app/bdsh");
     262        getvc("vc5", "/app/bdsh");
     263        getvc("vc6", "/app/klog");
     264       
     265        usleep(1000000);
     266        spawn("/srv/dd");
     267       
    312268        return 0;
    313269}
Note: See TracChangeset for help on using the changeset viewer.