Changeset 3b3e776 in mainline for uspace/app/init/init.c
- Timestamp:
- 2010-02-05T10:57:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0358da0
- Parents:
- 3f085132 (diff), b4cbef1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/init/init.c
r3f085132 r3b3e776 50 50 #include "init.h" 51 51 52 #define DEVFS_MOUNT_POINT "/dev" 53 54 #define SRV_CONSOLE "/srv/console" 55 #define APP_GETTERM "/app/getterm" 56 52 57 static void info_print(void) 53 58 { … … 58 63 { 59 64 char *opts = ""; 60 const char *root_dev = " initrd";65 const char *root_dev = "bd/initrd"; 61 66 62 67 if (str_cmp(fstype, "tmpfs") == 0) … … 89 94 static bool mount_devfs(void) 90 95 { 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); 96 int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING); 101 97 102 98 switch (rc) { … … 106 102 case EBUSY: 107 103 printf(NAME ": Device filesystem already mounted\n"); 108 devmap_null_destroy(null_id); 104 109 105 return false; 110 106 case ELIMIT: 111 107 printf(NAME ": Unable to mount device filesystem\n"); 112 devmap_null_destroy(null_id); 108 113 109 return false; 114 110 case ENOENT: 115 111 printf(NAME ": Unknown filesystem type (devfs)\n"); 116 devmap_null_destroy(null_id); 112 117 113 return false; 118 114 default: 119 115 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 120 devmap_null_destroy(null_id); 116 121 117 return false; 122 118 } … … 170 166 } 171 167 172 if ( texit != TASK_EXIT_NORMAL || retval != 0) {168 if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) { 173 169 printf(NAME ": Server %s failed to start (returned %d)\n", 174 170 fname, retval); … … 176 172 } 177 173 178 static void getvc(char *dev, char *app)179 { 180 char *argv[ 4];181 char vc[MAX_DEVICE_NAME];174 static void console(char *dev) 175 { 176 char *argv[3]; 177 char hid_in[DEVMAP_NAME_MAXLEN]; 182 178 int rc; 183 179 184 snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev); 185 186 printf(NAME ": Spawning getvc on %s\n", vc); 187 180 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 181 182 printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in); 183 184 /* Wait for the input device to be ready */ 188 185 dev_handle_t handle; 189 186 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 190 187 191 188 if (rc == EOK) { 192 argv[0] = "/app/getvc"; 193 argv[1] = vc; 189 argv[0] = SRV_CONSOLE; 190 argv[1] = hid_in; 191 argv[2] = NULL; 192 193 if (!task_spawn(SRV_CONSOLE, argv)) 194 printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in); 195 } else 196 printf(NAME ": Error waiting on %s\n", hid_in); 197 } 198 199 static void getterm(char *dev, char *app) 200 { 201 char *argv[4]; 202 char term[DEVMAP_NAME_MAXLEN]; 203 int rc; 204 205 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 206 207 printf(NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app); 208 209 /* Wait for the terminal device to be ready */ 210 dev_handle_t handle; 211 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 212 213 if (rc == EOK) { 214 argv[0] = APP_GETTERM; 215 argv[1] = term; 194 216 argv[2] = app; 195 217 argv[3] = NULL; 196 218 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 204 static void mount_ data(void)219 if (!task_spawn(APP_GETTERM, argv)) 220 printf(NAME ": Error spawning %s with %s %s\n", APP_GETTERM, 221 term, app); 222 } else 223 printf(NAME ": Error waiting on %s\n", term); 224 } 225 226 static void mount_scratch(void) 205 227 { 206 228 int rc; 207 229 208 printf("Trying to mount disk0 on /data... ");230 printf("Trying to mount null/0 on /scratch... "); 209 231 fflush(stdout); 210 232 211 rc = mount(" fat", "/data", "disk0", "wtcache", 0);233 rc = mount("tmpfs", "/scratch", "null/0", "", 0); 212 234 if (rc == EOK) 213 235 printf("OK\n"); … … 216 238 } 217 239 240 static void mount_data(void) 241 { 242 int rc; 243 244 printf("Trying to mount bd/disk0 on /data... "); 245 fflush(stdout); 246 247 rc = mount("fat", "/data", "bd/disk0", "wtcache", 0); 248 if (rc == EOK) 249 printf("OK\n"); 250 else 251 printf("Failed\n"); 252 } 253 218 254 int main(int argc, char *argv[]) 219 255 { … … 224 260 return -1; 225 261 } 262 263 /* Make sure tmpfs is running. */ 264 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 265 spawn("/srv/tmpfs"); 266 } 226 267 227 268 spawn("/srv/devfs"); 269 spawn("/srv/taskmon"); 228 270 229 271 if (!mount_devfs()) { … … 231 273 return -2; 232 274 } 233 275 276 mount_scratch(); 277 278 spawn("/srv/fhc"); 279 spawn("/srv/obio"); 280 srv_start("/srv/cuda_adb"); 281 srv_start("/srv/i8042"); 282 srv_start("/srv/adb_ms"); 283 srv_start("/srv/char_ms"); 284 234 285 spawn("/srv/fb"); 235 286 spawn("/srv/kbd"); 236 spawn("/srv/console");237 spawn("/srv/fhc");238 spawn("/srv/ obio");287 console("hid_in/kbd"); 288 289 spawn("/srv/clip"); 239 290 240 291 /* … … 255 306 #endif 256 307 257 get vc("vc0", "/app/bdsh");258 get vc("vc1", "/app/bdsh");259 get vc("vc2", "/app/bdsh");260 get vc("vc3", "/app/bdsh");261 get vc("vc4", "/app/bdsh");262 get vc("vc5", "/app/bdsh");263 get vc("vc6", "/app/klog");264 308 getterm("term/vc0", "/app/bdsh"); 309 getterm("term/vc1", "/app/bdsh"); 310 getterm("term/vc2", "/app/bdsh"); 311 getterm("term/vc3", "/app/bdsh"); 312 getterm("term/vc4", "/app/bdsh"); 313 getterm("term/vc5", "/app/bdsh"); 314 getterm("term/vc6", "/app/klog"); 315 265 316 usleep(1000000); 266 317 spawn("/srv/dd");
Note:
See TracChangeset
for help on using the changeset viewer.