Changeset 45e7868 in mainline
- Timestamp:
- 2011-11-07T23:02:28Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8c62a71
- Parents:
- a0c05e7 (diff), 7b5f4c9 (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
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/acpi/madt.c
ra0c05e7 r45e7868 116 116 static int madt_irq_to_pin(unsigned int irq) 117 117 { 118 ASSERT(irq < sizeof(isa_irq_map) / sizeof(int)); 118 if (irq >= sizeof(isa_irq_map) / sizeof(int)) 119 return (int) irq; 119 120 120 121 return isa_irq_map[irq]; … … 178 179 ASSERT(override->source < sizeof(isa_irq_map) / sizeof(int)); 179 180 180 printf("MADT: Ignoring %s entry: bus=%" PRIu8 ", source=%" PRIu8 181 ", global_int=%" PRIu32 ", flags=%#" PRIx16 "\n", 182 entry[override->header.type], override->bus, override->source, 183 override->global_int, override->flags); 181 isa_irq_map[override->source] = override->global_int; 184 182 } 185 183 -
uspace/app/bdsh/cmds/modules/cp/cp.c
ra0c05e7 r45e7868 33 33 #include <str.h> 34 34 #include <fcntl.h> 35 #include <sys/stat.h> 36 #include <dirent.h> 35 37 #include "config.h" 36 38 #include "util.h" … … 55 57 }; 56 58 59 typedef enum { 60 TYPE_NONE, 61 TYPE_FILE, 62 TYPE_DIR 63 } dentry_type_t; 64 65 static int64_t copy_file(const char *src, const char *dest, 66 size_t blen, int vb); 67 68 /** Get the type of a directory entry. 69 * 70 * @param path Path of the directory entry. 71 * 72 * @return TYPE_DIR if the dentry is a directory. 73 * @return TYPE_FILE if the dentry is a file. 74 * @return TYPE_NONE if the dentry does not exists. 75 */ 76 static dentry_type_t get_type(const char *path) 77 { 78 struct stat s; 79 80 int r = stat(path, &s); 81 82 if (r) 83 return TYPE_NONE; 84 else if (s.is_directory) 85 return TYPE_DIR; 86 else if (s.is_file) 87 return TYPE_FILE; 88 89 return TYPE_NONE; 90 } 91 57 92 static int strtoint(const char *s1) 58 93 { … … 67 102 return (int) t1; 68 103 } 104 105 /** Get the last component of a path. 106 * 107 * e.g. /data/a ---> a 108 * 109 * @param path Pointer to the path. 110 * 111 * @return Pointer to the last component or to the path itself. 112 */ 113 static char *get_last_path_component(char *path) 114 { 115 char *ptr; 116 117 ptr = str_rchr(path, '/'); 118 if (!ptr) 119 return path; 120 else 121 return ptr + 1; 122 } 123 124 /** Merge two paths together. 125 * 126 * e.g. (path1 = /data/dir, path2 = a/b) --> /data/dir/a/b 127 * 128 * @param path1 Path to which path2 will be appended. 129 * @param path1_size Size of the path1 buffer. 130 * @param path2 Path that will be appended to path1. 131 */ 132 static void merge_paths(char *path1, size_t path1_size, char *path2) 133 { 134 const char *delim = "/"; 135 136 str_rtrim(path1, '/'); 137 str_append(path1, path1_size, delim); 138 str_append(path1, path1_size, path2); 139 } 140 141 static int64_t do_copy(const char *src, const char *dest, 142 size_t blen, int vb, int recursive, int force) 143 { 144 int r = -1; 145 char dest_path[PATH_MAX]; 146 char src_path[PATH_MAX]; 147 DIR *dir = NULL; 148 struct dirent *dp; 149 150 dentry_type_t src_type = get_type(src); 151 dentry_type_t dest_type = get_type(dest); 152 153 const size_t src_len = str_size(src); 154 155 if (src_type == TYPE_FILE) { 156 char *src_fname; 157 158 /* Initialize the src_path with the src argument */ 159 str_cpy(src_path, src_len + 1, src); 160 str_rtrim(src_path, '/'); 161 162 /* Get the last component name from the src path */ 163 src_fname = get_last_path_component(src_path); 164 165 /* Initialize dest_path with the dest argument */ 166 str_cpy(dest_path, PATH_MAX, dest); 167 168 if (dest_type == TYPE_DIR) { 169 /* e.g. cp file_name /data */ 170 /* e.g. cp file_name /data/ */ 171 172 /* dest is a directory, 173 * append the src filename to it. 174 */ 175 merge_paths(dest_path, PATH_MAX, src_fname); 176 dest_type = get_type(dest_path); 177 } else if (dest_type == TYPE_NONE) { 178 if (dest_path[str_size(dest_path) - 1] == '/') { 179 /* e.g. cp /textdemo /data/dirnotexists/ */ 180 181 printf("The dest directory %s does not exists", 182 dest_path); 183 goto exit; 184 } 185 } 186 187 if (dest_type == TYPE_DIR) { 188 printf("Cannot overwrite existing directory %s\n", 189 dest_path); 190 goto exit; 191 } else if (dest_type == TYPE_FILE) { 192 /* e.g. cp file_name existing_file */ 193 194 /* dest already exists, if force is set we will 195 * try to remove it. 196 */ 197 if (force) { 198 if (unlink(dest_path)) { 199 printf("Unable to remove %s\n", 200 dest_path); 201 goto exit; 202 } 203 } else { 204 printf("file already exists: %s\n", dest_path); 205 goto exit; 206 } 207 } 208 209 /* call copy_file and exit */ 210 r = (copy_file(src, dest_path, blen, vb) < 0); 211 212 } else if (src_type == TYPE_DIR) { 213 /* e.g. cp -r /x/srcdir /y/destdir/ */ 214 215 if (!recursive) { 216 printf("Cannot copy the %s directory without the " 217 "-r option\n", src); 218 goto exit; 219 } else if (dest_type == TYPE_FILE) { 220 printf("Cannot overwrite a file with a directory\n"); 221 goto exit; 222 } 223 224 char *src_dirname; 225 226 /* Initialize src_path with the content of src */ 227 str_cpy(src_path, src_len + 1, src); 228 str_rtrim(src_path, '/'); 229 230 src_dirname = get_last_path_component(src_path); 231 232 str_cpy(dest_path, PATH_MAX, dest); 233 234 switch (dest_type) { 235 case TYPE_DIR: 236 if (str_cmp(src_dirname, "..") && 237 str_cmp(src_dirname, ".")) { 238 /* The last component of src_path is 239 * not '.' or '..' 240 */ 241 merge_paths(dest_path, PATH_MAX, src_dirname); 242 243 if (mkdir(dest_path, 0) == -1) { 244 printf("Unable to create " 245 "dest directory %s\n", dest_path); 246 goto exit; 247 } 248 } 249 break; 250 default: 251 case TYPE_NONE: 252 /* dest does not exists, this means the user wants 253 * to specify the name of the destination directory 254 * 255 * e.g. cp -r /src /data/new_dir_src 256 */ 257 if (mkdir(dest_path, 0)) { 258 printf("Unable to create " 259 "dest directory %s\n", dest_path); 260 goto exit; 261 } 262 break; 263 } 264 265 dir = opendir(src); 266 if (!dir) { 267 /* Something strange is happening... */ 268 printf("Unable to open src %s directory\n", src); 269 goto exit; 270 } 271 272 /* Copy every single directory entry of src into the 273 * destination directory. 274 */ 275 while ((dp = readdir(dir))) { 276 struct stat src_s; 277 struct stat dest_s; 278 279 char src_dent[PATH_MAX]; 280 char dest_dent[PATH_MAX]; 281 282 str_cpy(src_dent, PATH_MAX, src); 283 merge_paths(src_dent, PATH_MAX, dp->d_name); 284 285 str_cpy(dest_dent, PATH_MAX, dest_path); 286 merge_paths(dest_dent, PATH_MAX, dp->d_name); 287 288 /* Check if we are copying a directory into itself */ 289 stat(src_dent, &src_s); 290 stat(dest_path, &dest_s); 291 292 if (dest_s.index == src_s.index && 293 dest_s.fs_handle == src_s.fs_handle) { 294 printf("Cannot copy a directory " 295 "into itself\n"); 296 goto exit; 297 } 298 299 if (vb) 300 printf("copy %s %s\n", src_dent, dest_dent); 301 302 /* Recursively call do_copy() */ 303 r = do_copy(src_dent, dest_dent, blen, vb, recursive, 304 force); 305 if (r) 306 goto exit; 307 308 } 309 } else 310 printf("Unable to open source file %s\n", src); 311 312 exit: 313 if (dir) 314 closedir(dir); 315 return r; 316 } 317 69 318 70 319 static int64_t copy_file(const char *src, const char *dest, … … 127 376 static char helpfmt[] = 128 377 "Usage: %s [options] <source> <dest>\n" 129 "Options: (* indicates not yet implemented)\n"378 "Options:\n" 130 379 " -h, --help A short option summary\n" 131 380 " -v, --version Print version information and exit\n" 132 "* -V, --verbose Be annoyingly noisy about what's being done\n" 133 "* -f, --force Do not complain when <dest> exists\n" 134 "* -r, --recursive Copy entire directories\n" 135 " -b, --buffer ## Set the read buffer size to ##\n" 136 "Currently, %s is under development, some options may not work.\n"; 381 " -V, --verbose Be annoyingly noisy about what's being done\n" 382 " -f, --force Do not complain when <dest> exists\n" 383 " -r, --recursive Copy entire directories\n" 384 " -b, --buffer ## Set the read buffer size to ##\n"; 137 385 if (level == HELP_SHORT) { 138 386 printf("`%s' copies files and directories\n", cmdname); 139 387 } else { 140 388 help_cmd_cp(HELP_SHORT); 141 printf(helpfmt, cmdname , cmdname);389 printf(helpfmt, cmdname); 142 390 } 143 391 … … 148 396 { 149 397 unsigned int argc, verbose = 0; 150 int buffer = 0; 398 int buffer = 0, recursive = 0; 399 int force = 0; 151 400 int c, opt_ind; 152 401 int64_t ret; … … 167 416 break; 168 417 case 'f': 418 force = 1; 169 419 break; 170 420 case 'r': 421 recursive = 1; 171 422 break; 172 423 case 'b': … … 194 445 } 195 446 196 ret = copy_file(argv[optind], argv[optind + 1], buffer, verbose); 197 198 if (verbose) 199 printf("%" PRId64 " bytes copied\n", ret); 200 201 if (ret >= 0) 447 ret = do_copy(argv[optind], argv[optind + 1], buffer, verbose, 448 recursive, force); 449 450 if (ret == 0) 202 451 return CMD_SUCCESS; 203 452 else -
uspace/app/bdsh/cmds/modules/mount/mount.c
ra0c05e7 r45e7868 30 30 #include <stdlib.h> 31 31 #include <vfs/vfs.h> 32 #include <adt/list.h> 32 33 #include <errno.h> 33 34 #include <getopt.h> 35 #include <inttypes.h> 34 36 #include "config.h" 35 37 #include "util.h" … … 60 62 } 61 63 return; 64 } 65 66 static void print_mtab_list(void) 67 { 68 LIST_INITIALIZE(mtab_list); 69 get_mtab_list(&mtab_list); 70 71 mtab_ent_t *old_ent = NULL; 72 73 list_foreach(mtab_list, cur) { 74 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 75 link); 76 77 if (old_ent) 78 free(old_ent); 79 80 old_ent = mtab_ent; 81 82 printf("%s", mtab_ent->fs_name); 83 if (mtab_ent->instance) 84 printf("/%d", mtab_ent->instance); 85 printf(" on %s ", mtab_ent->mp); 86 87 if (str_size(mtab_ent->opts) > 0) 88 printf("opts=%s ", mtab_ent->opts); 89 90 printf("(service=%" PRIun ")\n", mtab_ent->service_id); 91 } 92 93 if (old_ent) 94 free(old_ent); 62 95 } 63 96 … … 94 127 t_argv = &argv[0]; 95 128 96 if ((argc < 3) || (argc > 5)) {129 if ((argc == 2) || (argc > 5)) { 97 130 printf("%s: invalid number of arguments. Try `mount --help'\n", 98 131 cmdname); 99 132 return CMD_FAILURE; 133 } 134 if (argc == 1) { 135 print_mtab_list(); 136 return CMD_SUCCESS; 100 137 } 101 138 if (argc > 3) -
uspace/dist/src/c/demos/tetris/screen.c
ra0c05e7 r45e7868 95 95 { 96 96 console_flush(console); 97 console_set_rgb_color(console, 0xffffff,98 use_color ? color : 0x000000);97 console_set_rgb_color(console, use_color ? color : 0x000000, 98 0xffffff); 99 99 } 100 100 … … 153 153 return false; 154 154 155 return ( ccap >= CONSOLE_CCAP_RGB);155 return ((ccap & CONSOLE_CAP_RGB) == CONSOLE_CAP_RGB); 156 156 } 157 157 -
uspace/drv/bus/pci/pciintel/pci.c
ra0c05e7 r45e7868 78 78 #define PCI_BUS_FROM_FUN(fun) ((fun)->busptr) 79 79 80 /** Max is 47, align to something nice. */ 81 #define ID_MAX_STR_LEN 50 82 80 83 static hw_resource_list_t *pciintel_get_resources(ddf_fun_t *fnode) 81 84 { … … 225 228 fibril_mutex_lock(&bus->conf_mutex); 226 229 227 uint32_t conf_addr; 228 conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 230 const uint32_t conf_addr = CONF_ADDR(fun->bus, fun->dev, fun->fn, reg); 229 231 void *addr = bus->conf_data_port + (reg & 3); 230 232 … … 311 313 void pci_fun_create_match_ids(pci_fun_t *fun) 312 314 { 313 char *match_id_str;314 315 int rc; 315 316 asprintf(&match_id_str, "pci/ven=%04x&dev=%04x", 316 char match_id_str[ID_MAX_STR_LEN]; 317 318 /* Vendor ID & Device ID, length(incl \0) 22 */ 319 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/ven=%04x&dev=%04x", 317 320 fun->vendor_id, fun->device_id); 318 319 if (match_id_str == NULL) { 320 ddf_msg(LVL_ERROR, "Out of memory creating match ID."); 321 return; 321 if (rc < 0) { 322 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 323 str_error(rc)); 322 324 } 323 325 324 326 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 90); 325 327 if (rc != EOK) { 326 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", 328 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 329 } 330 331 /* Class, subclass, prog IF, revision, length(incl \0) 47 */ 332 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 333 "pci/class=%02x&subclass=%02x&progif=%02x&revision=%02x", 334 fun->class_code, fun->subclass_code, fun->prog_if, fun->revision); 335 if (rc < 0) { 336 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 327 337 str_error(rc)); 328 338 } 329 330 free(match_id_str); 331 332 /* TODO add more ids (with subsys ids, using class id etc.) */ 339 340 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 70); 341 if (rc != EOK) { 342 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 343 } 344 345 /* Class, subclass, prog IF, length(incl \0) 35 */ 346 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 347 "pci/class=%02x&subclass=%02x&progif=%02x", 348 fun->class_code, fun->subclass_code, fun->prog_if); 349 if (rc < 0) { 350 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 351 str_error(rc)); 352 } 353 354 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 60); 355 if (rc != EOK) { 356 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 357 } 358 359 /* Class, subclass, length(incl \0) 25 */ 360 rc = snprintf(match_id_str, ID_MAX_STR_LEN, 361 "pci/class=%02x&subclass=%02x", 362 fun->class_code, fun->subclass_code); 363 if (rc < 0) { 364 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 365 str_error(rc)); 366 } 367 368 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 50); 369 if (rc != EOK) { 370 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 371 } 372 373 /* Class, length(incl \0) 13 */ 374 rc = snprintf(match_id_str, ID_MAX_STR_LEN, "pci/class=%02x", 375 fun->class_code); 376 if (rc < 0) { 377 ddf_msg(LVL_ERROR, "Failed creating match ID str: %s", 378 str_error(rc)); 379 } 380 381 rc = ddf_fun_add_match_id(fun->fnode, match_id_str, 40); 382 if (rc != EOK) { 383 ddf_msg(LVL_ERROR, "Failed adding match ID: %s", str_error(rc)); 384 } 385 386 /* TODO add subsys ids, but those exist only in header type 0 */ 333 387 } 334 388 … … 481 535 for (fnum = 0; multi && fnum < 8; fnum++) { 482 536 pci_fun_init(fun, bus_num, dnum, fnum); 483 fun->vendor_id = pci_conf_read_16(fun,484 PCI_VENDOR_ID);485 fun->device_id = pci_conf_read_16(fun,486 PCI_DEVICE_ID);487 537 if (fun->vendor_id == 0xffff) { 488 538 /* … … 511 561 512 562 fnode = ddf_fun_create(bus->dnode, fun_inner, fun_name); 563 free(fun_name); 513 564 if (fnode == NULL) { 514 565 ddf_msg(LVL_ERROR, "Failed creating function."); … … 516 567 } 517 568 518 free(fun_name);519 569 fun->fnode = fnode; 520 570 … … 691 741 fun->dev = dev; 692 742 fun->fn = fn; 743 fun->vendor_id = pci_conf_read_16(fun, PCI_VENDOR_ID); 744 fun->device_id = pci_conf_read_16(fun, PCI_DEVICE_ID); 745 fun->class_code = pci_conf_read_8(fun, PCI_BASE_CLASS); 746 fun->subclass_code = pci_conf_read_8(fun, PCI_SUB_CLASS); 747 fun->prog_if = pci_conf_read_8(fun, PCI_PROG_IF); 748 fun->revision = pci_conf_read_8(fun, PCI_REVISION_ID); 693 749 } 694 750 … … 711 767 bool pci_alloc_resource_list(pci_fun_t *fun) 712 768 { 713 fun->hw_resources.resources = 714 (hw_resource_t *) malloc(PCI_MAX_HW_RES * sizeof(hw_resource_t)); 715 return fun->hw_resources.resources != NULL; 769 fun->hw_resources.resources = fun->resources; 770 return true; 716 771 } 717 772 718 773 void pci_clean_resource_list(pci_fun_t *fun) 719 774 { 720 if (fun->hw_resources.resources != NULL) { 721 free(fun->hw_resources.resources); 722 fun->hw_resources.resources = NULL; 723 } 775 fun->hw_resources.resources = NULL; 724 776 } 725 777 -
uspace/drv/bus/pci/pciintel/pci.h
ra0c05e7 r45e7868 60 60 int vendor_id; 61 61 int device_id; 62 uint8_t class_code; 63 uint8_t subclass_code; 64 uint8_t prog_if; 65 uint8_t revision; 62 66 hw_resource_list_t hw_resources; 67 hw_resource_t resources[PCI_MAX_HW_RES]; 63 68 } pci_fun_t; 64 69 -
uspace/lib/c/generic/str.c
ra0c05e7 r45e7868 839 839 840 840 return NULL; 841 } 842 843 /** Removes specified trailing characters from a string. 844 * 845 * @param str String to remove from. 846 * @param ch Character to remove. 847 */ 848 void str_rtrim(char *str, wchar_t ch) 849 { 850 size_t off = 0; 851 size_t pos = 0; 852 wchar_t c; 853 bool update_last_chunk = true; 854 char *last_chunk = NULL; 855 856 while ((c = str_decode(str, &off, STR_NO_LIMIT))) { 857 if (c != ch) { 858 update_last_chunk = true; 859 last_chunk = NULL; 860 } else if (update_last_chunk) { 861 update_last_chunk = false; 862 last_chunk = (str + pos); 863 } 864 pos = off; 865 } 866 867 if (last_chunk) 868 *last_chunk = '\0'; 869 } 870 871 /** Removes specified leading characters from a string. 872 * 873 * @param str String to remove from. 874 * @param ch Character to remove. 875 */ 876 void str_ltrim(char *str, wchar_t ch) 877 { 878 wchar_t acc; 879 size_t off = 0; 880 size_t pos = 0; 881 size_t str_sz = str_size(str); 882 883 while ((acc = str_decode(str, &off, STR_NO_LIMIT)) != 0) { 884 if (acc != ch) 885 break; 886 else 887 pos = off; 888 } 889 890 if (pos > 0) { 891 memmove(str, &str[pos], str_sz - pos); 892 pos = str_sz - pos; 893 str[str_sz - pos] = '\0'; 894 } 841 895 } 842 896 -
uspace/lib/c/generic/vfs/vfs.c
ra0c05e7 r45e7868 831 831 } 832 832 833 int get_mtab_list(list_t *mtab_list) 834 { 835 sysarg_t rc; 836 aid_t req; 837 size_t i; 838 sysarg_t num_mounted_fs; 839 840 async_exch_t *exch = vfs_exchange_begin(); 841 842 req = async_send_0(exch, VFS_IN_MTAB_GET, NULL); 843 844 /* Ask VFS how many filesystems are mounted */ 845 rc = async_req_0_1(exch, VFS_IN_PING, &num_mounted_fs); 846 if (rc != EOK) 847 goto exit; 848 849 for (i = 0; i < num_mounted_fs; ++i) { 850 mtab_ent_t *mtab_ent; 851 852 mtab_ent = malloc(sizeof(mtab_ent_t)); 853 if (!mtab_ent) { 854 rc = ENOMEM; 855 goto exit; 856 } 857 858 memset(mtab_ent, 0, sizeof(mtab_ent_t)); 859 860 rc = async_data_read_start(exch, (void *) mtab_ent->mp, 861 MAX_PATH_LEN); 862 if (rc != EOK) 863 goto exit; 864 865 rc = async_data_read_start(exch, (void *) mtab_ent->opts, 866 MAX_MNTOPTS_LEN); 867 if (rc != EOK) 868 goto exit; 869 870 rc = async_data_read_start(exch, (void *) mtab_ent->fs_name, 871 FS_NAME_MAXLEN); 872 if (rc != EOK) 873 goto exit; 874 875 sysarg_t p[2]; 876 877 rc = async_req_0_2(exch, VFS_IN_PING, &p[0], &p[1]); 878 if (rc != EOK) 879 goto exit; 880 881 mtab_ent->instance = p[0]; 882 mtab_ent->service_id = p[1]; 883 884 link_initialize(&mtab_ent->link); 885 list_append(&mtab_ent->link, mtab_list); 886 } 887 888 exit: 889 async_wait_for(req, &rc); 890 vfs_exchange_end(exch); 891 return rc; 892 } 893 833 894 /** @} 834 895 */ -
uspace/lib/c/include/ipc/vfs.h
ra0c05e7 r45e7868 42 42 #define FS_NAME_MAXLEN 20 43 43 #define MAX_PATH_LEN (64 * 1024) 44 #define MAX_MNTOPTS_LEN 256 44 45 #define PLB_SIZE (2 * MAX_PATH_LEN) 45 46 … … 80 81 VFS_IN_DUP, 81 82 VFS_IN_WAIT_HANDLE, 83 VFS_IN_MTAB_GET, 82 84 } vfs_in_request_t; 83 85 -
uspace/lib/c/include/str.h
ra0c05e7 r45e7868 91 91 extern char *str_rchr(const char *str, wchar_t ch); 92 92 93 extern void str_rtrim(char *str, wchar_t ch); 94 extern void str_ltrim(char *str, wchar_t ch); 95 93 96 extern bool wstr_linsert(wchar_t *str, wchar_t ch, size_t pos, size_t max_pos); 94 97 extern bool wstr_remove(wchar_t *str, size_t pos); -
uspace/lib/c/include/vfs/vfs.h
ra0c05e7 r45e7868 39 39 #include <ipc/vfs.h> 40 40 #include <ipc/loc.h> 41 #include <adt/list.h> 41 42 #include <stdio.h> 42 43 #include <async.h> 44 #include "vfs_mtab.h" 43 45 44 46 enum vfs_change_state_type { … … 55 57 56 58 extern int fd_wait(void); 59 extern int get_mtab_list(list_t *mtab_list); 57 60 58 61 extern async_exch_t *vfs_exchange_begin(void); -
uspace/lib/drv/generic/driver.c
ra0c05e7 r45e7868 970 970 971 971 match_id->id = str_dup(match_id_str); 972 match_id->score = 90;972 match_id->score = match_score; 973 973 974 974 add_match_id(&fun->match_ids, match_id); -
uspace/srv/fs/mfs/mfs_ops.c
ra0c05e7 r45e7868 384 384 if (flags & L_DIRECTORY) { 385 385 ino_i->i_mode = S_IFDIR; 386 ino_i->i_nlinks = 2; /* This accounts for the '.' dentry */387 } else {386 ino_i->i_nlinks = 1; /* This accounts for the '.' dentry */ 387 } else 388 388 ino_i->i_mode = S_IFREG; 389 ino_i->i_nlinks = 1;390 }391 389 392 390 ino_i->i_uid = 0; … … 675 673 if (r != EOK) 676 674 goto exit_error; 675 676 child->ino_i->i_nlinks++; 677 child->ino_i->dirty = true; 677 678 678 679 if (S_ISDIR(child->ino_i->i_mode)) { -
uspace/srv/hw/irc/apic/apic.c
ra0c05e7 r45e7868 133 133 // FIXME: get the map from the kernel, even though this may work 134 134 // for simple cases 135 if (irq == 0) 136 return 2; 135 137 return irq; 136 138 } -
uspace/srv/vfs/vfs.c
ra0c05e7 r45e7868 127 127 vfs_wait_handle(callid, &call); 128 128 break; 129 case VFS_IN_MTAB_GET: 130 vfs_get_mtab(callid, &call); 131 break; 129 132 default: 130 133 async_answer_0(callid, ENOTSUP); -
uspace/srv/vfs/vfs.h
ra0c05e7 r45e7868 150 150 extern list_t fs_list; /**< List of registered file systems. */ 151 151 152 extern fibril_mutex_t fs_mntlist_lock; 153 extern list_t fs_mntlist; /**< List of mounted file systems. */ 154 152 155 extern vfs_pair_t rootfs; /**< Root file system. */ 153 156 … … 162 165 extern uint8_t *plb; /**< Path Lookup Buffer */ 163 166 extern list_t plb_entries; /**< List of active PLB entries. */ 164 165 #define MAX_MNTOPTS_LEN 256166 167 167 168 /** Holding this rwlock prevents changes in file system namespace. */ … … 219 220 extern void vfs_rename(ipc_callid_t, ipc_call_t *); 220 221 extern void vfs_wait_handle(ipc_callid_t, ipc_call_t *); 222 extern void vfs_get_mtab(ipc_callid_t, ipc_call_t *); 221 223 222 224 #endif -
uspace/srv/vfs/vfs_ops.c
ra0c05e7 r45e7868 52 52 #include <assert.h> 53 53 #include <vfs/canonify.h> 54 #include <vfs/vfs_mtab.h> 55 56 FIBRIL_MUTEX_INITIALIZE(mtab_list_lock); 57 LIST_INITIALIZE(mtab_list); 58 static size_t mtab_size = 0; 54 59 55 60 /* Forward declarations of static functions. */ … … 68 73 }; 69 74 70 static voidvfs_mount_internal(ipc_callid_t rid, service_id_t service_id,75 static int vfs_mount_internal(ipc_callid_t rid, service_id_t service_id, 71 76 fs_handle_t fs_handle, char *mp, char *opts) 72 77 { … … 91 96 fibril_rwlock_write_unlock(&namespace_rwlock); 92 97 async_answer_0(rid, EBUSY); 93 return ;98 return EBUSY; 94 99 } 95 100 … … 99 104 fibril_rwlock_write_unlock(&namespace_rwlock); 100 105 async_answer_0(rid, rc); 101 return ;106 return rc; 102 107 } 103 108 … … 106 111 fibril_rwlock_write_unlock(&namespace_rwlock); 107 112 async_answer_0(rid, ENOMEM); 108 return ;113 return ENOMEM; 109 114 } 110 115 … … 135 140 fibril_rwlock_write_unlock(&namespace_rwlock); 136 141 async_answer_0(rid, rc); 137 return ;142 return rc; 138 143 } 139 144 async_wait_for(msg, &rc); … … 142 147 fibril_rwlock_write_unlock(&namespace_rwlock); 143 148 async_answer_0(rid, rc); 144 return ;149 return rc; 145 150 } 146 151 … … 166 171 fibril_rwlock_write_unlock(&namespace_rwlock); 167 172 async_answer_0(rid, rc); 168 return ;173 return rc; 169 174 } else { 170 175 /* … … 174 179 fibril_rwlock_write_unlock(&namespace_rwlock); 175 180 async_answer_0(rid, ENOENT); 176 return ;181 return ENOENT; 177 182 } 178 183 } … … 207 212 async_answer_0(rid, rc); 208 213 fibril_rwlock_write_unlock(&namespace_rwlock); 209 return ;214 return rc; 210 215 } 211 216 … … 222 227 fibril_rwlock_write_unlock(&namespace_rwlock); 223 228 async_answer_0(rid, rc); 224 return ;229 return rc; 225 230 } 226 231 … … 258 263 async_answer_0(rid, rc); 259 264 fibril_rwlock_write_unlock(&namespace_rwlock); 265 return rc; 260 266 } 261 267 … … 352 358 } 353 359 fibril_mutex_unlock(&fs_list_lock); 354 355 /* Acknowledge that we know fs_name. */ 356 async_answer_0(callid, EOK); 357 360 361 /* Add the filesystem info to the list of mounted filesystems */ 362 mtab_ent_t *mtab_ent = malloc(sizeof(mtab_ent_t)); 363 if (!mtab_ent) { 364 async_answer_0(callid, ENOMEM); 365 async_answer_0(rid, ENOMEM); 366 free(mp); 367 free(fs_name); 368 free(opts); 369 return; 370 } 371 358 372 /* Do the mount */ 359 vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 373 rc = vfs_mount_internal(rid, service_id, fs_handle, mp, opts); 374 if (rc != EOK) { 375 async_answer_0(callid, ENOTSUP); 376 async_answer_0(rid, ENOTSUP); 377 free(mtab_ent); 378 free(mp); 379 free(opts); 380 free(fs_name); 381 return; 382 } 383 384 /* Add the filesystem info to the list of mounted filesystems */ 385 386 str_cpy(mtab_ent->mp, MAX_PATH_LEN, mp); 387 str_cpy(mtab_ent->fs_name, FS_NAME_MAXLEN, fs_name); 388 str_cpy(mtab_ent->opts, MAX_MNTOPTS_LEN, opts); 389 mtab_ent->instance = instance; 390 mtab_ent->service_id = service_id; 391 392 link_initialize(&mtab_ent->link); 393 394 fibril_mutex_lock(&mtab_list_lock); 395 list_append(&mtab_ent->link, &mtab_list); 396 mtab_size++; 397 fibril_mutex_unlock(&mtab_list_lock); 398 360 399 free(mp); 361 400 free(fs_name); 362 401 free(opts); 402 403 /* Acknowledge that we know fs_name. */ 404 async_answer_0(callid, EOK); 363 405 } 364 406 … … 433 475 */ 434 476 435 free(mp);436 437 477 exch = vfs_exchange_grab(mr_node->fs_handle); 438 478 rc = async_req_1_0(exch, VFS_OUT_UNMOUNTED, … … 442 482 if (rc != EOK) { 443 483 fibril_rwlock_write_unlock(&namespace_rwlock); 484 free(mp); 444 485 vfs_node_put(mr_node); 445 486 async_answer_0(rid, rc); … … 459 500 460 501 rc = vfs_lookup_internal(mp, L_MP, &mp_res, NULL); 461 free(mp);462 502 if (rc != EOK) { 463 503 fibril_rwlock_write_unlock(&namespace_rwlock); 504 free(mp); 464 505 vfs_node_put(mr_node); 465 506 async_answer_0(rid, rc); … … 470 511 if (!mp_node) { 471 512 fibril_rwlock_write_unlock(&namespace_rwlock); 513 free(mp); 472 514 vfs_node_put(mr_node); 473 515 async_answer_0(rid, ENOMEM); … … 482 524 if (rc != EOK) { 483 525 fibril_rwlock_write_unlock(&namespace_rwlock); 526 free(mp); 484 527 vfs_node_put(mp_node); 485 528 vfs_node_put(mr_node); … … 499 542 */ 500 543 vfs_node_forget(mr_node); 501 502 544 fibril_rwlock_write_unlock(&namespace_rwlock); 545 546 fibril_mutex_lock(&mtab_list_lock); 547 548 int found = 0; 549 550 list_foreach(mtab_list, cur) { 551 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 552 link); 553 554 if (str_cmp(mtab_ent->mp, mp) == 0) { 555 list_remove(&mtab_ent->link); 556 mtab_size--; 557 free(mtab_ent); 558 found = 1; 559 break; 560 } 561 } 562 assert(found); 563 fibril_mutex_unlock(&mtab_list_lock); 564 565 free(mp); 566 503 567 async_answer_0(rid, EOK); 504 568 } … … 1289 1353 } 1290 1354 1355 void vfs_get_mtab(ipc_callid_t rid, ipc_call_t *request) 1356 { 1357 ipc_callid_t callid; 1358 ipc_call_t data; 1359 sysarg_t rc = EOK; 1360 size_t len; 1361 1362 fibril_mutex_lock(&mtab_list_lock); 1363 1364 /* Send to the caller the number of mounted filesystems */ 1365 callid = async_get_call(&data); 1366 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) { 1367 rc = ENOTSUP; 1368 async_answer_0(callid, rc); 1369 goto exit; 1370 } 1371 async_answer_1(callid, EOK, mtab_size); 1372 1373 list_foreach(mtab_list, cur) { 1374 mtab_ent_t *mtab_ent = list_get_instance(cur, mtab_ent_t, 1375 link); 1376 1377 rc = ENOTSUP; 1378 1379 if (!async_data_read_receive(&callid, &len)) { 1380 async_answer_0(callid, rc); 1381 goto exit; 1382 } 1383 1384 (void) async_data_read_finalize(callid, mtab_ent->mp, 1385 str_size(mtab_ent->mp)); 1386 1387 if (!async_data_read_receive(&callid, &len)) { 1388 async_answer_0(callid, rc); 1389 goto exit; 1390 } 1391 1392 (void) async_data_read_finalize(callid, mtab_ent->opts, 1393 str_size(mtab_ent->opts)); 1394 1395 if (!async_data_read_receive(&callid, &len)) { 1396 async_answer_0(callid, rc); 1397 goto exit; 1398 } 1399 1400 (void) async_data_read_finalize(callid, mtab_ent->fs_name, 1401 str_size(mtab_ent->fs_name)); 1402 1403 callid = async_get_call(&data); 1404 1405 if (IPC_GET_IMETHOD(data) != VFS_IN_PING) { 1406 async_answer_0(callid, rc); 1407 goto exit; 1408 } 1409 1410 rc = EOK; 1411 async_answer_2(callid, rc, mtab_ent->instance, 1412 mtab_ent->service_id); 1413 } 1414 1415 exit: 1416 fibril_mutex_unlock(&mtab_list_lock); 1417 async_answer_0(rid, rc); 1418 } 1419 1291 1420 /** 1292 1421 * @}
Note:
See TracChangeset
for help on using the changeset viewer.