| 621 | } |
| 622 | |
| 623 | FSDevice *fs_disk_init(const char *root_path) |
| 624 | { |
| 625 | FSDeviceDisk *fs; |
| 626 | struct stat st; |
| 627 | |
| 628 | lstat(root_path, &st); |
| 629 | if (!S_ISDIR(st.st_mode)) |
| 630 | return NULL; |
| 631 | |
| 632 | fs = mallocz(sizeof(*fs)); |
| 633 | |
| 634 | fs->common.fs_end = fs_disk_end; |
| 635 | fs->common.fs_delete = fs_delete; |
| 636 | fs->common.fs_statfs = fs_statfs; |
| 637 | fs->common.fs_attach = fs_attach; |
| 638 | fs->common.fs_walk = fs_walk; |
| 639 | fs->common.fs_mkdir = fs_mkdir; |
| 640 | fs->common.fs_open = fs_open; |
| 641 | fs->common.fs_create = fs_create; |
| 642 | fs->common.fs_stat = fs_stat; |
| 643 | fs->common.fs_setattr = fs_setattr; |
| 644 | fs->common.fs_close = fs_close; |
| 645 | fs->common.fs_readdir = fs_readdir; |
| 646 | fs->common.fs_read = fs_read; |
| 647 | fs->common.fs_write = fs_write; |
| 648 | fs->common.fs_link = fs_link; |
| 649 | fs->common.fs_symlink = fs_symlink; |
| 650 | fs->common.fs_mknod = fs_mknod; |
| 651 | fs->common.fs_readlink = fs_readlink; |
| 652 | fs->common.fs_renameat = fs_renameat; |
| 653 | fs->common.fs_unlinkat = fs_unlinkat; |
| 654 | fs->common.fs_lock = fs_lock; |
| 655 | fs->common.fs_getlock = fs_getlock; |
| 656 | |
| 657 | fs->root_path = strdup(root_path); |
| 658 | return (FSDevice *)fs; |
| 659 | } |