Changes in uspace/app/init/init.c [73d8600:31e9fe0] in mainline


Ignore:
File:
1 edited

Legend:

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

    r73d8600 r31e9fe0  
    4949#include <loc.h>
    5050#include <str_error.h>
    51 #include <config.h>
    5251#include "init.h"
    5352
     
    6059#define TMPFS_FS_TYPE      "tmpfs"
    6160#define TMPFS_MOUNT_POINT  "/tmp"
     61
     62#define DATA_FS_TYPE      "fat"
     63#define DATA_DEVICE       "bd/ata1disk0"
     64#define DATA_MOUNT_POINT  "/data"
    6265
    6366#define SRV_CONSOLE  "/srv/console"
     
    127130                opts = "restore";
    128131       
    129         int rc = vfs_mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
     132        int rc = mount(fstype, ROOT_MOUNT_POINT, ROOT_DEVICE, opts,
    130133            IPC_FLAG_BLOCKING, 0);
    131134        return mount_report("Root filesystem", ROOT_MOUNT_POINT, fstype,
     
    144147static bool mount_locfs(void)
    145148{
    146         int rc = vfs_mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
     149        int rc = mount(LOCFS_FS_TYPE, LOCFS_MOUNT_POINT, "", "",
    147150            IPC_FLAG_BLOCKING, 0);
    148151        return mount_report("Location service filesystem", LOCFS_MOUNT_POINT,
     
    153156{
    154157        struct stat s;
    155         if (stat(path, &s) != 0) {
     158        if (stat(path, &s) == ENOENT) {
    156159                printf("%s: Unable to stat %s\n", NAME, path);
    157160                return ENOENT;
     
    173176        va_start(ap, path);
    174177        task_id_t id;
    175         task_wait_t wait;
    176         int rc = task_spawn(&id, &wait, path, cnt, ap);
     178        int rc = task_spawn(&id, path, cnt, ap);
    177179        va_end(ap);
    178180       
     
    191193        task_exit_t texit;
    192194        int retval;
    193         rc = task_wait(&wait, &texit, &retval);
     195        rc = task_wait(id, &texit, &retval);
    194196        if (rc != EOK) {
    195197                printf("%s: Error waiting for %s (%s)\n", NAME, path,
     
    255257       
    256258        task_id_t id;
    257         task_wait_t wait;
    258         int rc = task_spawnl(&id, &wait, app, app, winreg, NULL);
     259        int rc = task_spawnl(&id, app, app, winreg, NULL);
    259260        if (rc != EOK) {
    260261                printf("%s: Error spawning %s %s (%s)\n", NAME, app,
     
    265266        task_exit_t texit;
    266267        int retval;
    267         rc = task_wait(&wait, &texit, &retval);
     268        rc = task_wait(id, &texit, &retval);
    268269        if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) {
    269270                printf("%s: Error retrieving retval from %s (%s)\n", NAME,
     
    275276}
    276277
    277 static void getterm(const char *svc, const char *app, bool msg)
    278 {
    279         if (msg) {
    280                 printf("%s: Spawning %s %s %s --msg --wait -- %s\n", NAME,
    281                     APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    282                
    283                 int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    284                     LOCFS_MOUNT_POINT, "--msg", "--wait", "--", app, NULL);
    285                 if (rc != EOK)
    286                         printf("%s: Error spawning %s %s %s --msg --wait -- %s\n",
    287                             NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     278static void getterm(const char *svc, const char *app, bool wmsg)
     279{
     280        char term[LOC_NAME_MAXLEN];
     281        snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc);
     282       
     283        printf("%s: Spawning %s %s %s\n", NAME, APP_GETTERM, term, app);
     284       
     285        /* Wait for the terminal service to be ready */
     286        service_id_t service_id;
     287        int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);
     288        if (rc != EOK) {
     289                printf("%s: Error waiting on %s (%s)\n", NAME, term,
     290                    str_error(rc));
     291                return;
     292        }
     293       
     294        if (wmsg) {
     295                rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term,
     296                    app, NULL);
     297                if (rc != EOK) {
     298                        printf("%s: Error spawning %s -w %s %s (%s)\n", NAME,
     299                            APP_GETTERM, term, app, str_error(rc));
     300                }
    288301        } else {
    289                 printf("%s: Spawning %s %s %s --wait -- %s\n", NAME,
    290                     APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
    291                
    292                 int rc = task_spawnl(NULL, NULL, APP_GETTERM, APP_GETTERM, svc,
    293                     LOCFS_MOUNT_POINT, "--wait", "--", app, NULL);
    294                 if (rc != EOK)
    295                         printf("%s: Error spawning %s %s %s --wait -- %s\n",
    296                             NAME, APP_GETTERM, svc, LOCFS_MOUNT_POINT, app);
     302                rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app,
     303                    NULL);
     304                if (rc != EOK) {
     305                        printf("%s: Error spawning %s %s %s (%s)\n", NAME,
     306                            APP_GETTERM, term, app, str_error(rc));
     307                }
    297308        }
    298309}
     
    300311static bool mount_tmpfs(void)
    301312{
    302         int rc = vfs_mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);
     313        int rc = mount(TMPFS_FS_TYPE, TMPFS_MOUNT_POINT, "", "", 0, 0);
    303314        return mount_report("Temporary filesystem", TMPFS_MOUNT_POINT,
    304315            TMPFS_FS_TYPE, NULL, rc);
    305316}
    306317
     318static bool mount_data(void)
     319{
     320        int rc = mount(DATA_FS_TYPE, DATA_MOUNT_POINT, DATA_DEVICE, "wtcache", 0, 0);
     321        return mount_report("Data filesystem", DATA_MOUNT_POINT, DATA_FS_TYPE,
     322            DATA_DEVICE, rc);
     323}
     324
    307325int main(int argc, char *argv[])
    308326{
    309         int rc;
    310 
    311327        info_print();
    312328       
     
    320336                srv_start("/srv/tmpfs");
    321337       
    322         srv_start("/srv/klog");
    323338        srv_start("/srv/locfs");
    324339        srv_start("/srv/taskmon");
     
    334349        srv_start("/srv/apic");
    335350        srv_start("/srv/i8259");
    336         srv_start("/srv/icp-ic");
    337351        srv_start("/srv/obio");
    338352        srv_start("/srv/cuda_adb");
    339353        srv_start("/srv/s3c24xx_uart");
    340354        srv_start("/srv/s3c24xx_ts");
    341        
    342         srv_start("/srv/vbd");
    343         srv_start("/srv/volsrv");
    344355       
    345356        srv_start("/srv/loopip");
     
    349360        srv_start("/srv/udp");
    350361        srv_start("/srv/dnsrsrv");
    351         srv_start("/srv/dhcp");
    352         srv_start("/srv/nconfsrv");
    353362       
    354363        srv_start("/srv/clipboard");
    355364        srv_start("/srv/remcons");
    356365       
     366        /*
     367         * Start these synchronously so that mount_data() can be
     368         * non-blocking.
     369         */
     370#ifdef CONFIG_START_BD
     371        srv_start("/srv/ata_bd");
     372#endif
     373       
     374#ifdef CONFIG_MOUNT_DATA
     375        /* Make sure fat is running. */
     376        if (str_cmp(STRING(RDFMT), "fat") != 0)
     377                srv_start("/srv/fat");
     378       
     379        mount_data();
     380#else
     381        (void) mount_data;
     382#endif
     383       
    357384        srv_start("/srv/input", HID_INPUT);
    358385        srv_start("/srv/output", HID_OUTPUT);
    359         srv_start("/srv/hound");
    360        
    361         if (!config_key_exists("console")) {
    362                 rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
     386       
     387        int rc = compositor(HID_INPUT, HID_COMPOSITOR_SERVER);
     388        if (rc == EOK) {
     389                gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
     390                gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
     391        } else {
     392                rc = console(HID_INPUT, HID_OUTPUT);
    363393                if (rc == EOK) {
    364                         gui_start("/app/barber", HID_COMPOSITOR_SERVER);
    365                         gui_start("/app/vlaunch", HID_COMPOSITOR_SERVER);
    366                         gui_start("/app/vterm", HID_COMPOSITOR_SERVER);
     394                        getterm("term/vc0", "/app/bdsh", true);
     395                        getterm("term/vc1", "/app/bdsh", false);
     396                        getterm("term/vc2", "/app/bdsh", false);
     397                        getterm("term/vc3", "/app/bdsh", false);
     398                        getterm("term/vc4", "/app/bdsh", false);
     399                        getterm("term/vc5", "/app/bdsh", false);
     400                        getterm("term/vc6", "/app/klog", false);
    367401                }
    368402        }
    369403       
    370         rc = console(HID_INPUT, HID_OUTPUT);
    371         if (rc == EOK) {
    372                 getterm("term/vc0", "/app/bdsh", true);
    373                 getterm("term/vc1", "/app/bdsh", false);
    374                 getterm("term/vc2", "/app/bdsh", false);
    375                 getterm("term/vc3", "/app/bdsh", false);
    376                 getterm("term/vc4", "/app/bdsh", false);
    377                 getterm("term/vc5", "/app/bdsh", false);
    378         }
    379        
    380404        return 0;
    381405}
Note: See TracChangeset for help on using the changeset viewer.