Changeset 52c4264 in mainline for uspace/app
- Timestamp:
- 2012-08-17T12:23:52Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 267f235
- Parents:
- ae2c925 (diff), ad78054 (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. - Location:
- uspace/app
- Files:
-
- 9 added
- 12 edited
-
bdsh/cmds/modules/bdd/bdd.c (modified) (1 diff)
-
bdsh/input.c (modified) (1 diff)
-
blkdump/blkdump.c (modified) (1 diff)
-
edit/Makefile (modified) (1 diff)
-
edit/edit.c (modified) (20 diffs)
-
edit/search.c (added)
-
edit/search.h (added)
-
edit/search_impl.h (added)
-
edit/sheet.c (modified) (1 diff)
-
edit/sheet.h (modified) (1 diff)
-
ext2info/ext2info.c (modified) (1 diff)
-
init/init.c (modified) (9 diffs)
-
mkexfat/mkexfat.c (modified) (1 diff)
-
mkfat/mkfat.c (modified) (1 diff)
-
mkmfs/mkmfs.c (modified) (1 diff)
-
vdemo/Makefile (added)
-
vdemo/vdemo.c (added)
-
vlaunch/Makefile (added)
-
vlaunch/vlaunch.c (added)
-
vterm/Makefile (added)
-
vterm/vterm.c (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/bdd/bdd.c
rae2c925 r52c4264 38 38 #include "cmds.h" 39 39 40 #include < libblock.h>40 #include <block.h> 41 41 #include <loc.h> 42 42 #include <errno.h> -
uspace/app/bdsh/input.c
rae2c925 r52c4264 268 268 if (rc != EOK) { 269 269 /* Error in communication with console */ 270 cli_quit = 1; 270 271 return; 271 272 } -
uspace/app/blkdump/blkdump.c
rae2c925 r52c4264 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include < libblock.h>42 #include <block.h> 43 43 #include <mem.h> 44 44 #include <loc.h> -
uspace/app/edit/Makefile
rae2c925 r52c4264 33 33 SOURCES = \ 34 34 edit.c \ 35 sheet.c 35 sheet.c \ 36 search.c 36 37 37 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/edit/edit.c
rae2c925 r52c4264 1 1 /* 2 2 * Copyright (c) 2009 Jiri Svoboda 3 * Copyright (c) 2012 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 49 50 50 51 #include "sheet.h" 52 #include "search.h" 51 53 52 54 enum redraw_flags { … … 83 85 */ 84 86 int ideal_column; 87 88 char *previous_search; 89 bool previous_search_reverse; 85 90 } pane_t; 86 91 … … 140 145 static void delete_char_after(void); 141 146 static void caret_update(void); 142 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir); 143 static void caret_move_word_left(void); 144 static void caret_move_word_right(void); 145 static void caret_move_to_line(int row); 147 static void caret_move_relative(int drow, int dcolumn, enum dir_spec align_dir, bool select); 148 static void caret_move_absolute(int row, int column, enum dir_spec align_dir, bool select); 149 static void caret_move(spt_t spt, bool select, bool update_ideal_column); 150 static void caret_move_word_left(bool select); 151 static void caret_move_word_right(bool select); 146 152 static void caret_go_to_line_ask(void); 147 153 … … 149 155 static void selection_sel_all(void); 150 156 static void selection_sel_range(spt_t pa, spt_t pb); 151 static void selection_sel_prev_word(void);152 static void selection_sel_next_word(void);153 157 static void selection_get_points(spt_t *pa, spt_t *pb); 154 158 static void selection_delete(void); 155 159 static void selection_copy(void); 156 160 static void insert_clipboard_data(void); 161 162 static void search(char *pattern, bool reverse); 163 static void search_prompt(bool reverse); 164 static void search_repeat(void); 157 165 158 166 static void pt_get_sof(spt_t *pt); … … 163 171 static bool pt_is_delimiter(spt_t *pt); 164 172 static bool pt_is_punctuation(spt_t *pt); 173 static spt_t pt_find_word_left(spt_t spt); 174 static spt_t pt_find_word_left(spt_t spt); 175 165 176 static int tag_cmp(tag_t const *a, tag_t const *b); 166 177 static int spt_cmp(spt_t const *a, spt_t const *b); … … 173 184 { 174 185 kbd_event_t ev; 175 coord_t coord;176 186 bool new_file; 177 187 int rc; 178 179 spt_t pt;180 188 181 189 con = console_init(stdin, stdout); … … 197 205 198 206 /* Place caret at the beginning of file. */ 199 coord.row = coord.column = 1;200 sheet_get_cell_pt(doc.sh, &coord, dir_before, &pt);201 sheet_place_tag(doc.sh, & pt, &pane.caret_pos);202 pane.ideal_column = coord.column;207 spt_t sof; 208 pt_get_sof(&sof); 209 sheet_place_tag(doc.sh, &sof, &pane.caret_pos); 210 pane.ideal_column = 1; 203 211 204 212 if (argc == 2) { … … 216 224 new_file = true; 217 225 226 /* Place selection start tag. */ 227 sheet_place_tag(doc.sh, &sof, &pane.sel_start); 228 218 229 /* Move to beginning of file. */ 219 caret_move(-ED_INFTY, -ED_INFTY, dir_before); 220 221 /* Place selection start tag. */ 222 tag_get_pt(&pane.caret_pos, &pt); 223 sheet_place_tag(doc.sh, &pt, &pane.sel_start); 230 pt_get_sof(&sof); 231 caret_move(sof, true, true); 224 232 225 233 /* Initial display */ … … 369 377 static void key_handle_ctrl(kbd_event_t const *ev) 370 378 { 379 spt_t pt; 371 380 switch (ev->key) { 372 381 case KC_Q: … … 400 409 selection_sel_all(); 401 410 break; 402 case KC_W:403 if (selection_active())404 break;405 selection_sel_prev_word();406 selection_delete();407 break;408 411 case KC_RIGHT: 409 caret_move_word_right( );412 caret_move_word_right(false); 410 413 break; 411 414 case KC_LEFT: 412 caret_move_word_left( );415 caret_move_word_left(false); 413 416 break; 414 417 case KC_L: 415 418 caret_go_to_line_ask(); 416 419 break; 420 case KC_F: 421 search_prompt(false); 422 break; 423 case KC_N: 424 search_repeat(); 425 break; 426 case KC_HOME: 427 pt_get_sof(&pt); 428 caret_move(pt, false, true); 429 break; 430 case KC_END: 431 pt_get_eof(&pt); 432 caret_move(pt, false, true); 433 break; 417 434 default: 418 435 break; … … 422 439 static void key_handle_shift_ctrl(kbd_event_t const *ev) 423 440 { 441 spt_t pt; 424 442 switch(ev->key) { 425 443 case KC_LEFT: 426 selection_sel_prev_word();444 caret_move_word_left(true); 427 445 break; 428 446 case KC_RIGHT: 429 selection_sel_next_word(); 447 caret_move_word_right(true); 448 break; 449 case KC_F: 450 search_prompt(true); 451 break; 452 case KC_HOME: 453 pt_get_sof(&pt); 454 caret_move(pt, true, true); 455 break; 456 case KC_END: 457 pt_get_eof(&pt); 458 caret_move(pt, true, true); 430 459 break; 431 460 default: … … 435 464 436 465 /** Move caret while preserving or resetting selection. */ 437 static void caret_movement(int drow, int dcolumn, enum dir_spec align_dir, 438 bool select) 439 { 440 spt_t pt; 441 spt_t caret_pt; 466 static void caret_move(spt_t new_caret_pt, bool select, bool update_ideal_column) 467 { 468 spt_t old_caret_pt, old_sel_pt; 442 469 coord_t c_old, c_new; 443 470 bool had_sel; 444 471 445 472 /* Check if we had selection before. */ 446 tag_get_pt(&pane.caret_pos, &caret_pt); 447 tag_get_pt(&pane.sel_start, &pt); 448 had_sel = !spt_equal(&caret_pt, &pt); 449 450 caret_move(drow, dcolumn, align_dir); 473 tag_get_pt(&pane.caret_pos, &old_caret_pt); 474 tag_get_pt(&pane.sel_start, &old_sel_pt); 475 had_sel = !spt_equal(&old_caret_pt, &old_sel_pt); 476 477 /* Place tag of the caret */ 478 sheet_remove_tag(doc.sh, &pane.caret_pos); 479 sheet_place_tag(doc.sh, &new_caret_pt, &pane.caret_pos); 451 480 452 481 if (select == false) { 453 482 /* Move sel_start to the same point as caret. */ 454 483 sheet_remove_tag(doc.sh, &pane.sel_start); 455 tag_get_pt(&pane.caret_pos, &pt);456 sheet_place_tag(doc.sh, &pt, &pane.sel_start);457 } 458 484 sheet_place_tag(doc.sh, &new_caret_pt, &pane.sel_start); 485 } 486 487 spt_get_coord(&new_caret_pt, &c_new); 459 488 if (select) { 460 tag_get_pt(&pane.caret_pos, &pt); 461 spt_get_coord(&caret_pt, &c_old); 462 spt_get_coord(&pt, &c_new); 489 spt_get_coord(&old_caret_pt, &c_old); 463 490 464 491 if (c_old.row == c_new.row) … … 471 498 pane.rflags |= REDRAW_TEXT; 472 499 } 500 501 if (update_ideal_column) 502 pane.ideal_column = c_new.column; 503 504 caret_update(); 473 505 } 474 506 … … 477 509 switch (key) { 478 510 case KC_LEFT: 479 caret_move ment(0, -1, dir_before, select);511 caret_move_relative(0, -1, dir_before, select); 480 512 break; 481 513 case KC_RIGHT: 482 caret_move ment(0, 0, dir_after, select);514 caret_move_relative(0, 0, dir_after, select); 483 515 break; 484 516 case KC_UP: 485 caret_move ment(-1, 0, dir_before, select);517 caret_move_relative(-1, 0, dir_before, select); 486 518 break; 487 519 case KC_DOWN: 488 caret_move ment(+1, 0, dir_before, select);520 caret_move_relative(+1, 0, dir_before, select); 489 521 break; 490 522 case KC_HOME: 491 caret_move ment(0, -ED_INFTY, dir_before, select);523 caret_move_relative(0, -ED_INFTY, dir_after, select); 492 524 break; 493 525 case KC_END: 494 caret_move ment(0, +ED_INFTY, dir_before, select);526 caret_move_relative(0, +ED_INFTY, dir_before, select); 495 527 break; 496 528 case KC_PAGE_UP: 497 caret_move ment(-pane.rows, 0, dir_before, select);529 caret_move_relative(-pane.rows, 0, dir_before, select); 498 530 break; 499 531 case KC_PAGE_DOWN: 500 caret_move ment(+pane.rows, 0, dir_before, select);532 caret_move_relative(+pane.rows, 0, dir_before, select); 501 533 break; 502 534 default: … … 1012 1044 } 1013 1045 1014 /** Change the caret position.1046 /** Relatively move caret position. 1015 1047 * 1016 1048 * Moves caret relatively to the current position. Looking at the first … … 1018 1050 * to a new character cell, and thus a new character. Then we either go to the 1019 1051 * point before the the character or after it, depending on @a align_dir. 1052 * 1053 * @param select true if the selection tag should stay where it is 1020 1054 */ 1021 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir) 1055 static void caret_move_relative(int drow, int dcolumn, enum dir_spec align_dir, 1056 bool select) 1022 1057 { 1023 1058 spt_t pt; … … 1055 1090 */ 1056 1091 sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt); 1057 sheet_remove_tag(doc.sh, &pane.caret_pos);1058 sheet_place_tag(doc.sh, &pt, &pane.caret_pos);1059 1092 1060 1093 /* For non-vertical movement set the new value for @c ideal_column. */ 1061 if (!pure_vertical) { 1062 spt_get_coord(&pt, &coord); 1063 pane.ideal_column = coord.column; 1064 } 1065 1066 caret_update(); 1067 } 1068 1069 static void caret_move_word_left(void) 1070 { 1094 caret_move(pt, select, !pure_vertical); 1095 } 1096 1097 /** Absolutely move caret position. 1098 * 1099 * Moves caret to a specified position. We get to a new character cell, and 1100 * thus a new character. Then we either go to the point before the the character 1101 * or after it, depending on @a align_dir. 1102 * 1103 * @param select true if the selection tag should stay where it is 1104 */ 1105 static void caret_move_absolute(int row, int column, enum dir_spec align_dir, 1106 bool select) 1107 { 1108 coord_t coord; 1109 coord.row = row; 1110 coord.column = column; 1111 1071 1112 spt_t pt; 1072 1113 sheet_get_cell_pt(doc.sh, &coord, align_dir, &pt); 1114 1115 caret_move(pt, select, true); 1116 } 1117 1118 /** Find beginning of a word to the left of spt */ 1119 static spt_t pt_find_word_left(spt_t spt) 1120 { 1073 1121 do { 1074 caret_move(0, -1, dir_before); 1075 1076 tag_get_pt(&pane.caret_pos, &pt); 1077 1078 sheet_remove_tag(doc.sh, &pane.sel_start); 1079 sheet_place_tag(doc.sh, &pt, &pane.sel_start); 1080 } while (!pt_is_word_beginning(&pt)); 1081 1082 pane.rflags |= REDRAW_TEXT; 1083 } 1084 1085 static void caret_move_word_right(void) 1122 spt_prev_char(spt, &spt); 1123 } while (!pt_is_word_beginning(&spt)); 1124 return spt; 1125 } 1126 1127 /** Find beginning of a word to the right of spt */ 1128 static spt_t pt_find_word_right(spt_t spt) 1129 { 1130 do { 1131 spt_next_char(spt, &spt); 1132 } while (!pt_is_word_beginning(&spt)); 1133 return spt; 1134 } 1135 1136 static void caret_move_word_left(bool select) 1086 1137 { 1087 1138 spt_t pt; 1088 1089 do { 1090 caret_move(0, 0, dir_after); 1091 1092 tag_get_pt(&pane.caret_pos, &pt); 1093 1094 sheet_remove_tag(doc.sh, &pane.sel_start); 1095 sheet_place_tag(doc.sh, &pt, &pane.sel_start); 1096 } while (!pt_is_word_beginning(&pt)); 1097 1098 pane.rflags |= REDRAW_TEXT; 1099 } 1100 1101 /** Change the caret position to a beginning of a given line 1102 */ 1103 static void caret_move_to_line(int row) 1139 tag_get_pt(&pane.caret_pos, &pt); 1140 spt_t word_left = pt_find_word_left(pt); 1141 caret_move(word_left, select, true); 1142 } 1143 1144 static void caret_move_word_right(bool select) 1104 1145 { 1105 1146 spt_t pt; 1106 coord_t coord;1107 1108 1147 tag_get_pt(&pane.caret_pos, &pt); 1109 spt_get_coord(&pt, &coord); 1110 1111 caret_movement(row - coord.row, 0, dir_before, false); 1148 spt_t word_right = pt_find_word_right(pt); 1149 caret_move(word_right, select, true); 1112 1150 } 1113 1151 … … 1126 1164 int line = strtol(sline, &endptr, 10); 1127 1165 if (*endptr != '\0') { 1166 free(sline); 1128 1167 status_display("Invalid number entered."); 1129 1168 return; 1130 1169 } 1131 1132 caret_move_to_line(line); 1133 } 1134 1170 free(sline); 1171 1172 caret_move_absolute(line, pane.ideal_column, dir_before, false); 1173 } 1174 1175 /* Search operations */ 1176 static int search_spt_producer(void *data, wchar_t *ret) 1177 { 1178 assert(data != NULL); 1179 assert(ret != NULL); 1180 spt_t *spt = data; 1181 *ret = spt_next_char(*spt, spt); 1182 return EOK; 1183 } 1184 1185 static int search_spt_reverse_producer(void *data, wchar_t *ret) 1186 { 1187 assert(data != NULL); 1188 assert(ret != NULL); 1189 spt_t *spt = data; 1190 *ret = spt_prev_char(*spt, spt); 1191 return EOK; 1192 } 1193 1194 static int search_spt_mark(void *data, void **mark) 1195 { 1196 assert(data != NULL); 1197 assert(mark != NULL); 1198 spt_t *spt = data; 1199 spt_t *new = calloc(1, sizeof(spt_t)); 1200 *mark = new; 1201 if (new == NULL) 1202 return ENOMEM; 1203 *new = *spt; 1204 return EOK; 1205 } 1206 1207 static void search_spt_mark_free(void *data) 1208 { 1209 free(data); 1210 } 1211 1212 static search_ops_t search_spt_ops = { 1213 .equals = char_exact_equals, 1214 .producer = search_spt_producer, 1215 .mark = search_spt_mark, 1216 .mark_free = search_spt_mark_free, 1217 }; 1218 1219 static search_ops_t search_spt_reverse_ops = { 1220 .equals = char_exact_equals, 1221 .producer = search_spt_reverse_producer, 1222 .mark = search_spt_mark, 1223 .mark_free = search_spt_mark_free, 1224 }; 1225 1226 /** Ask for line and go to it. */ 1227 static void search_prompt(bool reverse) 1228 { 1229 char *pattern; 1230 1231 const char *prompt_text = "Find next"; 1232 if (reverse) 1233 prompt_text = "Find previous"; 1234 1235 const char *default_value = ""; 1236 if (pane.previous_search) 1237 default_value = pane.previous_search; 1238 1239 pattern = prompt(prompt_text, default_value); 1240 if (pattern == NULL) { 1241 status_display("Search cancelled."); 1242 return; 1243 } 1244 1245 if (pane.previous_search) 1246 free(pane.previous_search); 1247 pane.previous_search = pattern; 1248 pane.previous_search_reverse = reverse; 1249 1250 search(pattern, reverse); 1251 } 1252 1253 static void search_repeat(void) 1254 { 1255 if (pane.previous_search == NULL) { 1256 status_display("No previous search to repeat."); 1257 return; 1258 } 1259 1260 search(pane.previous_search, pane.previous_search_reverse); 1261 } 1262 1263 static void search(char *pattern, bool reverse) 1264 { 1265 status_display("Searching..."); 1266 1267 spt_t sp, producer_pos; 1268 tag_get_pt(&pane.caret_pos, &sp); 1269 1270 /* Start searching on the position before/after caret */ 1271 if (!reverse) { 1272 spt_next_char(sp, &sp); 1273 } 1274 else { 1275 spt_prev_char(sp, &sp); 1276 } 1277 producer_pos = sp; 1278 1279 search_ops_t ops = search_spt_ops; 1280 if (reverse) 1281 ops = search_spt_reverse_ops; 1282 1283 search_t *search = search_init(pattern, &producer_pos, ops, reverse); 1284 if (search == NULL) { 1285 status_display("Failed initializing search."); 1286 return; 1287 } 1288 1289 match_t match; 1290 int rc = search_next_match(search, &match); 1291 if (rc != EOK) { 1292 status_display("Failed searching."); 1293 search_fini(search); 1294 } 1295 1296 if (match.end) { 1297 status_display("Match found."); 1298 assert(match.end != NULL); 1299 spt_t *end = match.end; 1300 caret_move(*end, false, true); 1301 while (match.length > 0) { 1302 match.length--; 1303 if (reverse) { 1304 spt_next_char(*end, end); 1305 } 1306 else { 1307 spt_prev_char(*end, end); 1308 } 1309 } 1310 caret_move(*end, true, true); 1311 free(end); 1312 } 1313 else { 1314 status_display("Not found."); 1315 } 1316 1317 search_fini(search); 1318 } 1135 1319 1136 1320 /** Check for non-empty selection. */ … … 1202 1386 pane.rflags |= REDRAW_TEXT; 1203 1387 caret_update(); 1204 }1205 1206 /** Add the previous word to the selection */1207 static void selection_sel_prev_word(void)1208 {1209 spt_t cpt, wpt, spt, ept;1210 1211 selection_get_points(&spt, &ept);1212 1213 tag_get_pt(&pane.caret_pos, &cpt);1214 caret_move_word_left();1215 tag_get_pt(&pane.caret_pos, &wpt);1216 1217 if (spt_cmp(&spt, &cpt) == 0)1218 selection_sel_range(ept, wpt);1219 else1220 selection_sel_range(spt, wpt);1221 }1222 1223 /** Add the next word to the selection */1224 static void selection_sel_next_word(void)1225 {1226 spt_t cpt, wpt, spt, ept;1227 1228 selection_get_points(&spt, &ept);1229 1230 tag_get_pt(&pane.caret_pos, &cpt);1231 caret_move_word_right();1232 tag_get_pt(&pane.caret_pos, &wpt);1233 1234 if (spt_cmp(&ept, &cpt) == 0)1235 selection_sel_range(spt, wpt);1236 else1237 selection_sel_range(ept, wpt);1238 1388 } 1239 1389 -
uspace/app/edit/sheet.c
rae2c925 r52c4264 323 323 } 324 324 325 /** Get a character at spt and return next spt */ 326 wchar_t spt_next_char(spt_t spt, spt_t *next) 327 { 328 wchar_t ch = str_decode(spt.sh->data, &spt.b_off, spt.sh->text_size); 329 if (next) 330 *next = spt; 331 return ch; 332 } 333 334 wchar_t spt_prev_char(spt_t spt, spt_t *prev) 335 { 336 wchar_t ch = str_decode_reverse(spt.sh->data, &spt.b_off, spt.sh->text_size); 337 if (prev) 338 *prev = spt; 339 return ch; 340 } 341 325 342 /** Place a tag on the specified s-point. */ 326 343 void sheet_place_tag(sheet_t *sh, spt_t const *pt, tag_t *tag) -
uspace/app/edit/sheet.h
rae2c925 r52c4264 101 101 extern void spt_get_coord(spt_t const *, coord_t *); 102 102 extern bool spt_equal(spt_t const *, spt_t const *); 103 extern wchar_t spt_next_char(spt_t, spt_t *); 104 extern wchar_t spt_prev_char(spt_t, spt_t *); 103 105 104 106 extern void sheet_place_tag(sheet_t *, spt_t const *, tag_t *); -
uspace/app/ext2info/ext2info.c
rae2c925 r52c4264 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include < libblock.h>42 #include <block.h> 43 43 #include <mem.h> 44 44 #include <loc.h> -
uspace/app/init/init.c
rae2c925 r52c4264 37 37 #include <stdio.h> 38 38 #include <unistd.h> 39 #include <stdarg.h> 39 40 #include <vfs/vfs.h> 40 41 #include <bool.h> … … 65 66 #define SRV_CONSOLE "/srv/console" 66 67 #define APP_GETTERM "/app/getterm" 68 69 #define SRV_COMPOSITOR "/srv/compositor" 70 71 #define HID_INPUT "hid/input" 72 #define HID_OUTPUT "hid/output" 73 #define HID_COMPOSITOR_SERVER ":0" 74 75 #define srv_start(path, ...) \ 76 srv_startl(path, path, ##__VA_ARGS__, NULL) 67 77 68 78 /** Print banner */ … … 143 153 } 144 154 145 static void spawn(const char *fname) 146 { 147 int rc; 155 static int srv_startl(const char *path, ...) 156 { 148 157 struct stat s; 149 150 if (stat(fname, &s) == ENOENT) 151 return; 152 153 printf("%s: Spawning %s\n", NAME, fname); 154 rc = task_spawnl(NULL, fname, fname, NULL); 155 if (rc != EOK) { 156 printf("%s: Error spawning %s (%s)\n", NAME, fname, 157 str_error(rc)); 158 } 159 } 160 161 static void srv_start(const char *fname) 162 { 158 if (stat(path, &s) == ENOENT) { 159 printf("%s: Unable to stat %s\n", NAME, path); 160 return ENOENT; 161 } 162 163 printf("%s: Starting %s\n", NAME, path); 164 165 va_list ap; 166 const char *arg; 167 int cnt = 0; 168 169 va_start(ap, path); 170 do { 171 arg = va_arg(ap, const char *); 172 cnt++; 173 } while (arg != NULL); 174 va_end(ap); 175 176 va_start(ap, path); 163 177 task_id_t id; 178 int rc = task_spawn(&id, path, cnt, ap); 179 va_end(ap); 180 181 if (rc != EOK) { 182 printf("%s: Error spawning %s (%s)\n", NAME, path, 183 str_error(rc)); 184 return rc; 185 } 186 187 if (!id) { 188 printf("%s: Error spawning %s (invalid task id)\n", NAME, 189 path); 190 return EINVAL; 191 } 192 164 193 task_exit_t texit; 165 int rc, retval; 166 struct stat s; 167 168 if (stat(fname, &s) == ENOENT) 169 return; 170 171 printf("%s: Starting %s\n", NAME, fname); 172 rc = task_spawnl(&id, fname, fname, NULL); 173 if (!id) { 174 printf("%s: Error spawning %s (%s)\n", NAME, fname, 175 str_error(rc)); 176 return; 177 } 178 194 int retval; 179 195 rc = task_wait(id, &texit, &retval); 180 196 if (rc != EOK) { 181 printf("%s: Error waiting for %s (%s)\n", NAME, fname,182 str_error(rc)); 183 return ;197 printf("%s: Error waiting for %s (%s)\n", NAME, path, 198 str_error(rc)); 199 return rc; 184 200 } 185 201 186 202 if (texit != TASK_EXIT_NORMAL) { 187 203 printf("%s: Server %s failed to start (unexpectedly " 188 "terminated)\n", NAME, fname);189 return ;190 } 191 192 if (retval != 0) {204 "terminated)\n", NAME, path); 205 return EINVAL; 206 } 207 208 if (retval != 0) 193 209 printf("%s: Server %s failed to start (exit code %d)\n", NAME, 194 fname, retval); 195 } 196 } 197 198 static void console(const char *isvc, const char *fbsvc) 199 { 200 printf("%s: Spawning %s %s %s\n", NAME, SRV_CONSOLE, isvc, fbsvc); 201 210 path, retval); 211 212 return retval; 213 } 214 215 static int console(const char *isvc, const char *osvc) 216 { 202 217 /* Wait for the input service to be ready */ 203 218 service_id_t service_id; … … 206 221 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 207 222 str_error(rc)); 208 return; 209 } 210 211 /* Wait for the framebuffer service to be ready */ 212 rc = loc_service_get_id(fbsvc, &service_id, IPC_FLAG_BLOCKING); 213 if (rc != EOK) { 214 printf("%s: Error waiting on %s (%s)\n", NAME, fbsvc, 215 str_error(rc)); 216 return; 217 } 218 219 rc = task_spawnl(NULL, SRV_CONSOLE, SRV_CONSOLE, isvc, fbsvc, NULL); 220 if (rc != EOK) { 221 printf("%s: Error spawning %s %s %s (%s)\n", NAME, SRV_CONSOLE, 222 isvc, fbsvc, str_error(rc)); 223 } 223 return rc; 224 } 225 226 /* Wait for the output service to be ready */ 227 rc = loc_service_get_id(osvc, &service_id, IPC_FLAG_BLOCKING); 228 if (rc != EOK) { 229 printf("%s: Error waiting on %s (%s)\n", NAME, osvc, 230 str_error(rc)); 231 return rc; 232 } 233 234 return srv_start(SRV_CONSOLE, isvc, osvc); 235 } 236 237 static int compositor(const char *isvc, const char *name) 238 { 239 /* Wait for the input service to be ready */ 240 service_id_t service_id; 241 int rc = loc_service_get_id(isvc, &service_id, IPC_FLAG_BLOCKING); 242 if (rc != EOK) { 243 printf("%s: Error waiting on %s (%s)\n", NAME, isvc, 244 str_error(rc)); 245 return rc; 246 } 247 248 return srv_start(SRV_COMPOSITOR, isvc, name); 249 } 250 251 static int gui_start(const char *app, const char *srv_name) 252 { 253 char winreg[50]; 254 snprintf(winreg, sizeof(winreg), "%s%s%s", "comp", srv_name, "/winreg"); 255 256 printf("%s: Spawning %s %s\n", NAME, app, winreg); 257 258 task_id_t id; 259 int rc = task_spawnl(&id, app, app, winreg, NULL); 260 if (rc != EOK) { 261 printf("%s: Error spawning %s %s (%s)\n", NAME, app, 262 winreg, str_error(rc)); 263 return -1; 264 } 265 266 task_exit_t texit; 267 int retval; 268 rc = task_wait(id, &texit, &retval); 269 if ((rc != EOK) || (texit != TASK_EXIT_NORMAL)) { 270 printf("%s: Error retrieving retval from %s (%s)\n", NAME, 271 app, str_error(rc)); 272 return -1; 273 } 274 275 return retval; 224 276 } 225 277 … … 227 279 { 228 280 char term[LOC_NAME_MAXLEN]; 229 int rc;230 231 281 snprintf(term, LOC_NAME_MAXLEN, "%s/%s", LOCFS_MOUNT_POINT, svc); 232 282 … … 235 285 /* Wait for the terminal service to be ready */ 236 286 service_id_t service_id; 237 rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING);287 int rc = loc_service_get_id(svc, &service_id, IPC_FLAG_BLOCKING); 238 288 if (rc != EOK) { 239 289 printf("%s: Error waiting on %s (%s)\n", NAME, term, … … 279 329 if (!mount_root(STRING(RDFMT))) { 280 330 printf("%s: Exiting\n", NAME); 281 return -1;331 return 1; 282 332 } 283 333 284 334 /* Make sure tmpfs is running. */ 285 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 286 spawn("/srv/tmpfs"); 287 } 288 289 spawn("/srv/locfs"); 290 spawn("/srv/taskmon"); 335 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) 336 srv_start("/srv/tmpfs"); 337 338 srv_start("/srv/locfs"); 339 srv_start("/srv/taskmon"); 291 340 292 341 if (!mount_locfs()) { 293 342 printf("%s: Exiting\n", NAME); 294 return -2;343 return 2; 295 344 } 296 345 297 346 mount_tmpfs(); 298 347 299 s pawn("/srv/devman");300 s pawn("/srv/apic");301 s pawn("/srv/i8259");302 s pawn("/srv/obio");348 srv_start("/srv/devman"); 349 srv_start("/srv/apic"); 350 srv_start("/srv/i8259"); 351 srv_start("/srv/obio"); 303 352 srv_start("/srv/cuda_adb"); 304 353 srv_start("/srv/s3c24xx_uart"); 305 354 srv_start("/srv/s3c24xx_ts"); 306 355 307 spawn("/srv/loopip"); 308 spawn("/srv/ethip"); 309 spawn("/srv/inetsrv"); 310 spawn("/srv/tcp"); 311 spawn("/srv/udp"); 312 313 spawn("/srv/fb"); 314 spawn("/srv/input"); 315 console("hid/input", "hid/fb0"); 316 317 spawn("/srv/clipboard"); 318 spawn("/srv/remcons"); 356 srv_start("/srv/loopip"); 357 srv_start("/srv/ethip"); 358 srv_start("/srv/inetsrv"); 359 srv_start("/srv/tcp"); 360 srv_start("/srv/udp"); 361 362 srv_start("/srv/clipboard"); 363 srv_start("/srv/remcons"); 319 364 320 365 /* … … 325 370 srv_start("/srv/ata_bd"); 326 371 srv_start("/srv/gxe_bd"); 327 #else328 (void) srv_start;329 372 #endif 330 373 331 374 #ifdef CONFIG_MOUNT_DATA 332 375 /* Make sure fat is running. */ 333 if (str_cmp(STRING(RDFMT), "fat") != 0) {376 if (str_cmp(STRING(RDFMT), "fat") != 0) 334 377 srv_start("/srv/fat"); 335 }378 336 379 mount_data(); 337 380 #else … … 339 382 #endif 340 383 341 getterm("term/vc0", "/app/bdsh", true); 342 getterm("term/vc1", "/app/bdsh", false); 343 getterm("term/vc2", "/app/bdsh", false); 344 getterm("term/vc3", "/app/bdsh", false); 345 getterm("term/vc4", "/app/bdsh", false); 346 getterm("term/vc5", "/app/bdsh", false); 347 getterm("term/vc6", "/app/klog", false); 384 srv_start("/srv/input", HID_INPUT); 385 srv_start("/srv/output", HID_OUTPUT); 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); 393 if (rc == EOK) { 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); 401 } 402 } 348 403 349 404 return 0; -
uspace/app/mkexfat/mkexfat.c
rae2c925 r52c4264 38 38 39 39 #include <stdio.h> 40 #include < libblock.h>40 #include <block.h> 41 41 #include <assert.h> 42 42 #include <errno.h> -
uspace/app/mkfat/mkfat.c
rae2c925 r52c4264 40 40 #include <stdio.h> 41 41 #include <stdlib.h> 42 #include < libblock.h>42 #include <block.h> 43 43 #include <mem.h> 44 44 #include <loc.h> -
uspace/app/mkmfs/mkmfs.c
rae2c925 r52c4264 39 39 #include <stdio.h> 40 40 #include <stdlib.h> 41 #include < libblock.h>41 #include <block.h> 42 42 #include <unistd.h> 43 43 #include <errno.h>
Note:
See TracChangeset
for help on using the changeset viewer.
