int main (int argc, char **argv) { error_t err; mach_port_t bootstrap; /* Initialize the diskfs library, parse arguments, and open the store. This starts the first diskfs thread for us. */ store = diskfs_init_main (&startup_argp, argc, argv, &store_parsed, &bootstrap); if (store->size < SBLOCK_OFFS + SBLOCK_SIZE) ext2_panic ("device too small for superblock (%Ld bytes)", store->size); if (store->log2_blocks_per_page < 0) ext2_panic ("device block size (%zu) greater than page size (%zd)", store->block_size, vm_page_size); /* Map the entire disk. */ create_disk_pager (); pokel_init (&global_pokel, diskfs_disk_pager, disk_cache); map_hypermetadata (); /* Set diskfs_root_node to the root inode. */ err = diskfs_cached_lookup (EXT2_ROOT_INO, &diskfs_root_node); if (err) ext2_panic ("can't get root: %s", strerror (err)); else if ((diskfs_root_node->dn_stat.st_mode & S_IFMT) == 0) ext2_panic ("no root node!"); pthread_mutex_unlock (&diskfs_root_node->lock); /* Now that we are all set up to handle requests, and diskfs_root_node is set properly, it is safe to export our fsys control port to the outside world. */ diskfs_startup_diskfs (bootstrap, 0); /* and so we die, leaving others to do the real work. */ pthread_exit (NULL); /* NOTREACHED */ return 0; }
/* The user must define this function if she wants to use the node cache. Create and initialize a node. */ error_t diskfs_user_make_node (struct node **npp, struct lookup_context *ctx) { struct node *np; struct disknode *dn; /* Create the new node. */ np = diskfs_make_node_alloc (sizeof *dn); if (np == NULL) return ENOMEM; /* Format specific data for the new node. */ dn = diskfs_node_disknode (np); dn->dirents = 0; dn->dir_idx = 0; dn->pager = 0; pthread_rwlock_init (&dn->alloc_lock, NULL); pokel_init (&dn->indir_pokel, diskfs_disk_pager, disk_cache); *npp = np; return 0; }