| 460 | } |
| 461 | |
| 462 | static void dfs_devfs_mkdir(const char *fullpath, mode_t mode) |
| 463 | { |
| 464 | int len = rt_strlen(fullpath); |
| 465 | char *path = (char *)rt_malloc(len + 1); |
| 466 | |
| 467 | if (path) |
| 468 | { |
| 469 | int index = len - 1; |
| 470 | |
| 471 | rt_strcpy(path, fullpath); |
| 472 | |
| 473 | if (path[index] == '/') |
| 474 | { |
| 475 | path[index] = '\0'; |
| 476 | index --; |
| 477 | } |
| 478 | |
| 479 | while (path[index] != '/' && index >= 0) |
| 480 | { |
| 481 | index --; |
| 482 | } |
| 483 | |
| 484 | path[index] = '\0'; |
| 485 | |
| 486 | if (index > 0 && access(path, 0) != 0) |
| 487 | { |
| 488 | int i = 0; |
| 489 | |
| 490 | if (path[i] == '/') |
| 491 | { |
| 492 | i ++; |
| 493 | } |
| 494 | |
| 495 | while (index > i) |
| 496 | { |
| 497 | if (path[i] == '/') |
| 498 | { |
| 499 | path[i] = '\0'; |
| 500 | mkdir(path, mode); |
| 501 | path[i] = '/'; |
| 502 | } |
| 503 | |
| 504 | i ++; |
| 505 | } |
| 506 | |
| 507 | mkdir(path, mode); |
| 508 | } |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | void dfs_devfs_device_add(rt_device_t device) |
| 513 | { |