Changeset 81f70b4 in mainline
- Timestamp:
- 2012-03-31T18:14:08Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d5f99e6
- Parents:
- 95c9158 (diff), 2f4fa79 (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. - Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.build
r95c9158 r81f70b4 34 34 OPTIMIZATION = 3 35 35 36 DEFS = -DRELEASE=$(RELEASE) "-D NAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__36 DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__ 37 37 38 38 GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ -
boot/arch/ia64/src/main.c
r95c9158 r81f70b4 189 189 printf("\nInflating components ... "); 190 190 191 /* 192 * We will use the next available address for a copy of each component to 193 * make sure that inflate() works with disjunctive memory regions. 194 */ 195 top = ALIGN_UP(top, PAGE_SIZE); 196 191 197 for (i = cnt; i > 0; i--) { 192 198 printf("%s ", components[i - 1].name); 193 199 194 int err = inflate(components[i - 1].start, components[i - 1].size, 200 /* 201 * Copy the component to a location which is guaranteed not to 202 * overlap with the destination for inflate(). 203 */ 204 memmove((void *) top, components[i - 1].start, components[i - 1].size); 205 206 int err = inflate((void *) top, components[i - 1].size, 195 207 dest[i - 1], components[i - 1].inflated); 196 208 -
boot/generic/include/memstr.h
r95c9158 r81f70b4 36 36 37 37 extern void *memcpy(void *, const void *, size_t); 38 extern void *memmove(void *, const void *, size_t); 38 39 39 40 #endif -
boot/generic/src/memstr.c
r95c9158 r81f70b4 51 51 } 52 52 53 /** Move memory block with possible overlapping. 54 * 55 * Copy cnt bytes from src address to dst address. The source 56 * and destination memory areas may overlap. 57 * 58 * @param dst Destination address to copy to. 59 * @param src Source address to copy from. 60 * @param cnt Number of bytes to copy. 61 * 62 * @return Destination address. 63 * 64 */ 65 void *memmove(void *dst, const void *src, size_t cnt) 66 { 67 /* Nothing to do? */ 68 if (src == dst) 69 return dst; 70 71 /* Non-overlapping? */ 72 if ((dst >= src + cnt) || (src >= dst + cnt)) 73 return memcpy(dst, src, cnt); 74 75 uint8_t *dp; 76 const uint8_t *sp; 77 78 /* Which direction? */ 79 if (src > dst) { 80 /* Forwards. */ 81 dp = dst; 82 sp = src; 83 84 while (cnt-- != 0) 85 *dp++ = *sp++; 86 } else { 87 /* Backwards. */ 88 dp = dst + (cnt - 1); 89 sp = src + (cnt - 1); 90 91 while (cnt-- != 0) 92 *dp-- = *sp--; 93 } 94 95 return dst; 96 } 97 53 98 /** @} 54 99 */ -
boot/generic/src/version.c
r95c9158 r81f70b4 32 32 33 33 static const char *project = "HelenOS bootloader"; 34 static const char *copyright = "Copyright (c) 2001-2011 HelenOS project";34 static const char *copyright = STRING(COPYRIGHT); 35 35 static const char *release = STRING(RELEASE); 36 36 static const char *name = STRING(NAME); -
contrib/conf/mips32-gx.sh
r95c9158 r81f70b4 8 8 fi 9 9 10 gxemul $@ -E testmips -C R4000 -X image.boot -d d0:"$DISK_IMG"10 gxemul $@ -E oldtestmips -C R4000 -X image.boot -d d0:"$DISK_IMG" -
kernel/Makefile
r95c9158 r81f70b4 90 90 endif 91 91 92 DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-D NAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__92 DEFS = -DKERNEL -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" -D__$(BITS)_BITS__ -D__$(ENDIANESS)__ 93 93 94 94 GCC_CFLAGS = -I$(INCLUDES) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \ -
kernel/arch/ppc32/src/ppc32.c
r95c9158 r81f70b4 130 130 visual = VISUAL_INDIRECT_8; 131 131 break; 132 case 15: 133 visual = VISUAL_RGB_5_5_5_BE; 134 break; 132 135 case 16: 133 visual = VISUAL_RGB_5_ 5_5_BE;136 visual = VISUAL_RGB_5_6_5_BE; 134 137 break; 135 138 case 24: -
kernel/generic/include/str.h
r95c9158 r81f70b4 97 97 extern bool wstr_remove(wchar_t *str, size_t pos); 98 98 99 extern int str_uint64 (const char *, char **, unsigned int, bool, uint64_t *);99 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *); 100 100 101 101 extern void order_suffix(const uint64_t, uint64_t *, char *); -
kernel/generic/src/console/cmd.c
r95c9158 r81f70b4 906 906 ((char *) argv->buffer)[0] <= '9') { 907 907 uint64_t value; 908 rc = str_uint64 ((char *) argv->buffer, NULL, 0, true, &value);908 rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value); 909 909 if (rc == EOK) 910 910 addr = (uintptr_t) value; -
kernel/generic/src/console/kconsole.c
r95c9158 r81f70b4 472 472 /* It's a number - convert it */ 473 473 uint64_t value; 474 int rc = str_uint64 (text, NULL, 0, true, &value);474 int rc = str_uint64_t(text, NULL, 0, true, &value); 475 475 switch (rc) { 476 476 case EINVAL: -
kernel/generic/src/lib/str.c
r95c9158 r81f70b4 893 893 * 894 894 */ 895 int str_uint64 (const char *nptr, char **endptr, unsigned int base,895 int str_uint64_t(const char *nptr, char **endptr, unsigned int base, 896 896 bool strict, uint64_t *result) 897 897 { -
kernel/generic/src/main/version.c
r95c9158 r81f70b4 38 38 39 39 static const char *project = "SPARTAN kernel"; 40 static const char *copyright = "Copyright (c) 2001-2011 HelenOS project";40 static const char *copyright = STRING(COPYRIGHT); 41 41 static const char *release = STRING(RELEASE); 42 42 static const char *name = STRING(NAME); -
kernel/generic/src/sysinfo/stats.c
r95c9158 r81f70b4 474 474 /* Parse the task ID */ 475 475 task_id_t task_id; 476 if (str_uint64 (name, NULL, 0, true, &task_id) != EOK)476 if (str_uint64_t(name, NULL, 0, true, &task_id) != EOK) 477 477 return ret; 478 478 … … 545 545 /* Parse the thread ID */ 546 546 thread_id_t thread_id; 547 if (str_uint64 (name, NULL, 0, true, &thread_id) != EOK)547 if (str_uint64_t(name, NULL, 0, true, &thread_id) != EOK) 548 548 return ret; 549 549 … … 662 662 /* Parse the exception number */ 663 663 uint64_t excn; 664 if (str_uint64 (name, NULL, 0, true, &excn) != EOK)664 if (str_uint64_t(name, NULL, 0, true, &excn) != EOK) 665 665 return ret; 666 666 -
uspace/app/bdsh/cmds/modules/ls/ls.c
r95c9158 r81f70b4 42 42 #include <sort.h> 43 43 44 #include "ls.h" 44 45 #include "errors.h" 45 46 #include "config.h" … … 48 49 #include "cmds.h" 49 50 50 /* Various values that can be returned by ls_scope() */51 #define LS_BOGUS 052 #define LS_FILE 153 #define LS_DIR 254 55 /** Structure to represent a directory entry.56 *57 * Useful to keep together important information58 * for sorting directory entries.59 */60 struct dir_elem_t {61 char *name;62 struct stat s;63 };64 65 51 static const char *cmdname = "ls"; 52 53 static ls_job_t ls; 66 54 67 55 static struct option const long_options[] = { 68 56 { "help", no_argument, 0, 'h' }, 69 57 { "unsort", no_argument, 0, 'u' }, 58 { "recursive", no_argument, 0, 'r' }, 70 59 { 0, 0, 0, 0 } 71 60 }; 61 62 /* Prototypes for the ls command, excluding entry points. */ 63 static unsigned int ls_start(ls_job_t *); 64 static void ls_print(struct dir_elem_t *); 65 static int ls_cmp(void *, void *, void *); 66 static signed int ls_scan_dir(const char *, DIR *, struct dir_elem_t **); 67 static unsigned int ls_recursive(const char *, DIR *); 68 static unsigned int ls_scope(const char *, struct dir_elem_t *); 69 70 static unsigned int ls_start(ls_job_t *ls) 71 { 72 ls->recursive = 0; 73 ls->sort = 1; 74 75 return 1; 76 } 72 77 73 78 /** Print an entry. … … 92 97 } 93 98 94 95 99 /** Compare 2 directory elements. 96 100 * … … 127 131 * 0 otherwise. 128 132 */ 129 static void ls_scan_dir(const char *d, DIR *dirp, int sort) 133 static signed int ls_scan_dir(const char *d, DIR *dirp, 134 struct dir_elem_t **dir_list_ptr) 130 135 { 131 136 int alloc_blocks = 20; … … 140 145 141 146 if (!dirp) 142 return ;147 return -1; 143 148 144 149 buff = (char *) malloc(PATH_MAX); 145 150 if (!buff) { 146 151 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 147 return ;152 return -1; 148 153 } 149 154 … … 152 157 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 153 158 free(buff); 154 return ;159 return -1; 155 160 } 156 161 … … 187 192 } 188 193 189 if ( sort) {194 if (ls.sort) { 190 195 if (!qsort(&tosort[0], nbdirs, sizeof(struct dir_elem_t), 191 196 ls_cmp, NULL)) { … … 196 201 for (i = 0; i < nbdirs; i++) 197 202 ls_print(&tosort[i]); 203 204 /* Populate the directory list. */ 205 if (ls.recursive) { 206 tmp = (struct dir_elem_t *) realloc(*dir_list_ptr, 207 nbdirs * sizeof(struct dir_elem_t)); 208 if (!tmp) { 209 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 210 goto out; 211 } 212 *dir_list_ptr = tmp; 213 214 for (i = 0; i < nbdirs; i++) { 215 (*dir_list_ptr)[i].name = str_dup(tosort[i].name); 216 if (!(*dir_list_ptr)[i].name) { 217 cli_error(CL_ENOMEM, "ls: failed to scan %s", d); 218 goto out; 219 } 220 } 221 } 198 222 199 223 out: … … 202 226 free(tosort); 203 227 free(buff); 228 229 return nbdirs; 230 } 231 232 /** Visit a directory recursively. 233 * 234 * ls_recursive visits all the subdirectories recursively and 235 * prints the files and directories in them. 236 * 237 * @param path Path the current directory being visited. 238 * @param dirp Directory stream. 239 */ 240 static unsigned int ls_recursive(const char *path, DIR *dirp) 241 { 242 int i, nbdirs, ret; 243 unsigned int scope; 244 char *subdir_path; 245 DIR *subdirp; 246 struct dir_elem_t *dir_list; 247 248 const char * const trailing_slash = "/"; 249 250 nbdirs = 0; 251 dir_list = (struct dir_elem_t *) malloc(sizeof(struct dir_elem_t)); 252 253 printf("\n%s:\n", path); 254 255 subdir_path = (char *) malloc(PATH_MAX); 256 if (!subdir_path) { 257 ret = CMD_FAILURE; 258 goto out; 259 } 260 261 nbdirs = ls_scan_dir(path, dirp, &dir_list); 262 if (nbdirs == -1) { 263 ret = CMD_FAILURE; 264 goto out; 265 } 266 267 for (i = 0; i < nbdirs; ++i) { 268 memset(subdir_path, 0, PATH_MAX); 269 270 if (str_size(subdir_path) + str_size(path) + 1 <= PATH_MAX) 271 str_append(subdir_path, PATH_MAX, path); 272 if (path[str_size(path)-1] != '/' && 273 str_size(subdir_path) + str_size(trailing_slash) + 1 <= PATH_MAX) 274 str_append(subdir_path, PATH_MAX, trailing_slash); 275 if (str_size(subdir_path) + 276 str_size(dir_list[i].name) + 1 <= PATH_MAX) 277 str_append(subdir_path, PATH_MAX, dir_list[i].name); 278 279 scope = ls_scope(subdir_path, &dir_list[i]); 280 switch (scope) { 281 case LS_FILE: 282 break; 283 case LS_DIR: 284 subdirp = opendir(subdir_path); 285 if (!subdirp) { 286 /* May have been deleted between scoping it and opening it */ 287 cli_error(CL_EFAIL, "Could not stat %s", dir_list[i].name); 288 ret = CMD_FAILURE; 289 goto out; 290 } 291 292 ret = ls_recursive(subdir_path, subdirp); 293 closedir(subdirp); 294 if (ret == CMD_FAILURE) 295 goto out; 296 break; 297 case LS_BOGUS: 298 ret = CMD_FAILURE; 299 goto out; 300 } 301 } 302 303 ret = CMD_SUCCESS; 304 305 out: 306 for (i = 0; i < nbdirs; i++) 307 free(dir_list[i].name); 308 free(dir_list); 309 free(subdir_path); 310 311 return ret; 312 } 313 314 static unsigned int ls_scope(const char *path, struct dir_elem_t *de) 315 { 316 if (stat(path, &de->s)) { 317 cli_error(CL_ENOENT, path); 318 return LS_BOGUS; 319 } 320 321 if (de->s.is_file) 322 return LS_FILE; 323 else if (de->s.is_directory) 324 return LS_DIR; 325 326 return LS_BOGUS; 204 327 } 205 328 … … 215 338 "Options:\n" 216 339 " -h, --help A short option summary\n" 217 " -u, --unsort Do not sort directory entries\n", 340 " -u, --unsort Do not sort directory entries\n" 341 " -r, --recursive List subdirectories recursively\n", 218 342 cmdname); 219 343 } … … 228 352 DIR *dirp; 229 353 int c, opt_ind; 230 int sort = 1; 354 int ret = 0; 355 unsigned int scope; 356 357 if (!ls_start(&ls)) { 358 cli_error(CL_EFAIL, "%s: Could not initialize", cmdname); 359 return CMD_FAILURE; 360 } 231 361 232 362 argc = cli_count_args(argv); 233 363 234 364 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 235 c = getopt_long(argc, argv, "hu ", long_options, &opt_ind);365 c = getopt_long(argc, argv, "hur", long_options, &opt_ind); 236 366 switch (c) { 237 367 case 'h': … … 239 369 return CMD_SUCCESS; 240 370 case 'u': 241 sort = 0; 371 ls.sort = 0; 372 break; 373 case 'r': 374 ls.recursive = 1; 242 375 break; 243 376 } … … 251 384 return CMD_FAILURE; 252 385 } 253 memset(de.name, 0, sizeof(PATH_MAX));386 memset(de.name, 0, PATH_MAX); 254 387 255 388 if (argc == 0) … … 257 390 else 258 391 str_cpy(de.name, PATH_MAX, argv[optind]); 259 260 if (stat(de.name, &de.s)) { 261 cli_error(CL_ENOENT, de.name); 262 free(de.name); 263 return CMD_FAILURE; 264 } 265 266 if (de.s.is_file) { 392 393 scope = ls_scope(de.name, &de); 394 switch (scope) { 395 case LS_FILE: 267 396 ls_print(&de); 268 } else { 397 break; 398 case LS_DIR: 269 399 dirp = opendir(de.name); 270 400 if (!dirp) { … … 274 404 return CMD_FAILURE; 275 405 } 276 ls_scan_dir(de.name, dirp, sort); 406 if (ls.recursive) 407 ret = ls_recursive(de.name, dirp); 408 else 409 ret = ls_scan_dir(de.name, dirp, NULL); 410 277 411 closedir(dirp); 412 break; 413 case LS_BOGUS: 414 return CMD_FAILURE; 278 415 } 279 416 280 417 free(de.name); 281 418 282 return CMD_SUCCESS; 283 } 284 419 if (ret == -1 || ret == CMD_FAILURE) 420 return CMD_FAILURE; 421 else 422 return CMD_SUCCESS; 423 } 424 -
uspace/app/bdsh/cmds/modules/touch/entry.h
r95c9158 r81f70b4 7 7 8 8 #endif /* TOUCH_ENTRY_H */ 9 -
uspace/app/bdsh/cmds/modules/touch/touch.c
r95c9158 r81f70b4 27 27 */ 28 28 29 /* TODO: Options that people would expect, such as not creating the file if 30 * it doesn't exist, specifying the access time, etc */ 29 /* 30 * TODO: Options that people would expect, such as specifying the access time, 31 * etc. 32 */ 31 33 32 34 #include <stdio.h> … … 37 39 #include <sys/types.h> 38 40 #include <str.h> 41 #include <getopt.h> 42 #include <sys/stat.h> 43 #include <errno.h> 39 44 40 45 #include "config.h" … … 47 52 static const char *cmdname = "touch"; 48 53 54 static struct option const long_options[] = { 55 { "no-create", no_argument, 0, 'c' }, 56 { 0, 0, 0, 0 } 57 }; 58 49 59 /* Dispays help for touch in various levels */ 50 60 void help_cmd_touch(unsigned int level) 51 61 { 52 62 if (level == HELP_SHORT) { 53 printf("`%s' updates access times forfiles\n", cmdname);63 printf("`%s' updates access times of files\n", cmdname); 54 64 } else { 55 65 help_cmd_touch(HELP_SHORT); 56 printf(" `%s' <file>, if the file does not exist it will be " 57 "created\n", cmdname); 66 printf("Usage: `%s' [-c|--no-create] <file>...\n\n" 67 "If the file does not exist it will be created empty,\n" 68 "unless -c (--no-create) is supplied.\n\n" 69 "Options:\n" 70 " -c, --no-create Do not create new files\n", 71 cmdname); 58 72 } 59 73 60 74 return; 61 75 } … … 64 78 int cmd_touch(char **argv) 65 79 { 66 unsigned int argc, i = 0, ret = 0; 67 int fd; 80 unsigned int argc = cli_count_args(argv); 81 unsigned int i = 0; 82 unsigned int ret = 0; 83 int c; 84 int longind; 85 bool no_create = false; 86 struct stat file_stat; 87 int fd = -1; 68 88 char *buff = NULL; 69 89 70 90 DIR *dirp; 71 72 argc = cli_count_args(argv); 73 74 if (argc == 1) { 75 printf("%s - incorrect number of arguments. Try `help %s extended'\n", 76 cmdname, cmdname); 91 92 for (c = 0, optind = 0, longind = 0; c != -1; ) { 93 c = getopt_long(argc, argv, "c", long_options, &longind); 94 switch (c) { 95 case 'c': 96 no_create = true; 97 break; 98 } 99 } 100 101 if (argc - optind < 1) { 102 printf("%s: Incorrect number of arguments. Try `help %s extended'\n", 103 cmdname, cmdname); 77 104 return CMD_FAILURE; 78 105 } 79 80 for (i = 1; i < argc; i++) {106 107 for (i = optind; argv[i] != NULL; i++) { 81 108 buff = str_dup(argv[i]); 109 if (buff == NULL) { 110 cli_error(CL_ENOMEM, "Out of memory"); 111 ret++; 112 continue; 113 } 114 82 115 dirp = opendir(buff); 83 116 if (dirp) { 84 cli_error(CL_ENOTSUP, " %sis a directory", buff);117 cli_error(CL_ENOTSUP, "`%s' is a directory", buff); 85 118 closedir(dirp); 86 ret ++; 119 free(buff); 120 ret++; 87 121 continue; 88 122 } 89 90 fd = open(buff, O_RDWR | O_CREAT); 123 124 /* Check whether file exists if -c (--no-create) option is given */ 125 if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == EOK))) 126 fd = open(buff, O_RDWR | O_CREAT); 127 91 128 if (fd < 0) { 92 cli_error(CL_EFAIL, "Could not update / create %s ", buff); 93 ret ++; 129 cli_error(CL_EFAIL, "Could not update or create `%s'", buff); 130 free(buff); 131 ret++; 94 132 continue; 95 } else 133 } else { 96 134 close(fd); 97 135 fd = -1; 136 } 137 98 138 free(buff); 99 139 } 100 140 101 141 if (ret) 102 142 return CMD_FAILURE; … … 104 144 return CMD_SUCCESS; 105 145 } 106 -
uspace/app/bdsh/cmds/modules/touch/touch.h
r95c9158 r81f70b4 4 4 /* Prototypes for the touch command, excluding entry points */ 5 5 6 7 6 #endif /* TOUCH_H */ 8 -
uspace/app/bdsh/cmds/modules/touch/touch_def.h
r95c9158 r81f70b4 5 5 &help_cmd_touch, 6 6 }, 7 -
uspace/app/getterm/Makefile
r95c9158 r81f70b4 29 29 30 30 USPACE_PREFIX = ../.. 31 DEFS = -DRELEASE=$(RELEASE) "-D NAME=$(NAME)"31 DEFS = -DRELEASE=$(RELEASE) "-DCOPYRIGHT=$(COPYRIGHT)" "-DNAME=$(NAME)" 32 32 BINARY = getterm 33 33 -
uspace/app/getterm/version.c
r95c9158 r81f70b4 40 40 #include "version.h" 41 41 42 static const char *copyright = STRING(COPYRIGHT); 42 43 static const char *release = STRING(RELEASE); 43 44 static const char *name = STRING(NAME); … … 61 62 printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp); 62 63 printf("Running on %s (%s)\n", arch, term); 63 printf(" Copyright (c) 2001-2011 HelenOS project\n\n");64 printf("%s\n\n", copyright); 64 65 } 65 66 -
uspace/lib/c/generic/str.c
r95c9158 r81f70b4 1535 1535 * 1536 1536 */ 1537 int str_uint64 (const char *nptr, char **endptr, unsigned int base,1537 int str_uint64_t(const char *nptr, char **endptr, unsigned int base, 1538 1538 bool strict, uint64_t *result) 1539 1539 { -
uspace/lib/c/include/str.h
r95c9158 r81f70b4 106 106 extern int str_uint16_t(const char *, char **, unsigned int, bool, uint16_t *); 107 107 extern int str_uint32_t(const char *, char **, unsigned int, bool, uint32_t *); 108 extern int str_uint64 (const char *, char **, unsigned int, bool, uint64_t *);108 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *); 109 109 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *); 110 110 -
uspace/lib/usb/src/dev.c
r95c9158 r81f70b4 122 122 char *ptr; 123 123 124 rc = str_uint64 (path, &ptr, 10, false, &sid);124 rc = str_uint64_t(path, &ptr, 10, false, &sid); 125 125 if (rc != EOK) { 126 126 return false; -
version
r95c9158 r81f70b4 46 46 47 47 NAME = Sashimi 48 COPYRIGHT = Copyright (c) 2001-2012 HelenOS project
Note:
See TracChangeset
for help on using the changeset viewer.