Lines Matching refs:fsopts

151 ffs_prep_opts(fsinfo_t *fsopts)  in ffs_prep_opts()  argument
199 fsopts->fs_specific = ffs_opts; in ffs_prep_opts()
200 fsopts->fs_options = copy_opts(ffs_options); in ffs_prep_opts()
204 ffs_cleanup_opts(fsinfo_t *fsopts) in ffs_cleanup_opts() argument
206 free(fsopts->fs_specific); in ffs_cleanup_opts()
207 free(fsopts->fs_options); in ffs_cleanup_opts()
211 ffs_parse_opts(const char *option, fsinfo_t *fsopts) in ffs_parse_opts() argument
213 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_parse_opts()
214 option_t *ffs_options = fsopts->fs_options; in ffs_parse_opts()
220 assert(fsopts != NULL); in ffs_parse_opts()
252 ffs_makefs(const char *image, const char *dir, fsnode *root, fsinfo_t *fsopts) in ffs_makefs() argument
260 assert(fsopts != NULL); in ffs_makefs()
267 if (fsopts->minsize == 0 && fsopts->freeblockpc == 0 && in ffs_makefs()
268 fsopts->freeblocks == 0) in ffs_makefs()
269 ((ffs_opt_t *)fsopts->fs_specific)->min_inodes = true; in ffs_makefs()
273 ffs_validate(dir, root, fsopts); in ffs_makefs()
277 image, (long long)fsopts->size, (long long)fsopts->inodes); in ffs_makefs()
281 if (ffs_create_image(image, fsopts) == -1) in ffs_makefs()
285 fsopts->curinode = UFS_ROOTINO; in ffs_makefs()
293 if (! ffs_populate_dir(dir, root, fsopts)) in ffs_makefs()
302 superblock = fsopts->superblock; in ffs_makefs()
310 ffs_write_superblock(fsopts->superblock, fsopts); in ffs_makefs()
311 if (close(fsopts->fd) == -1) in ffs_makefs()
313 fsopts->fd = -1; in ffs_makefs()
321 ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts) in ffs_validate() argument
326 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_validate()
330 assert(fsopts != NULL); in ffs_validate()
335 ffs_dump_fsinfo(fsopts); in ffs_validate()
339 if (fsopts->sectorsize == -1) in ffs_validate()
340 fsopts->sectorsize = DFL_SECSIZE; in ffs_validate()
341 if (fsopts->sectorsize != DFL_SECSIZE) in ffs_validate()
343 fsopts->sectorsize); in ffs_validate()
345 ffs_opts->fsize = MAX(DFL_FRAGSIZE, fsopts->sectorsize); in ffs_validate()
370 if (fsopts->maxsize > 0 && in ffs_validate()
371 roundup(fsopts->minsize, ffs_opts->bsize) > fsopts->maxsize) in ffs_validate()
375 (long long)fsopts->minsize, ffs_opts->bsize, in ffs_validate()
376 (long long)fsopts->maxsize); in ffs_validate()
379 ffs_size_dir(root, fsopts); in ffs_validate()
380 fsopts->inodes += UFS_ROOTINO; /* include first two inodes */ in ffs_validate()
384 (long long)fsopts->size, (long long)fsopts->inodes); in ffs_validate()
387 fsopts->size += fsopts->freeblocks; in ffs_validate()
388 fsopts->inodes += fsopts->freefiles; in ffs_validate()
389 if (fsopts->freefilepc > 0) in ffs_validate()
390 fsopts->inodes = in ffs_validate()
391 fsopts->inodes * (100 + fsopts->freefilepc) / 100; in ffs_validate()
392 if (fsopts->freeblockpc > 0) in ffs_validate()
393 fsopts->size = in ffs_validate()
394 fsopts->size * (100 + fsopts->freeblockpc) / 100; in ffs_validate()
402 fsopts->size += in ffs_validate()
404 fsopts->size += roundup(SBLOCKSIZE, ffs_opts->bsize); in ffs_validate()
405 fsopts->size += ffs_opts->bsize; in ffs_validate()
406 fsopts->size += DINODE1_SIZE * in ffs_validate()
407 roundup(fsopts->inodes, ffs_opts->bsize / DINODE1_SIZE); in ffs_validate()
409 fsopts->size += in ffs_validate()
411 fsopts->size += roundup(SBLOCKSIZE, ffs_opts->bsize); in ffs_validate()
412 fsopts->size += ffs_opts->bsize; in ffs_validate()
413 fsopts->size += DINODE2_SIZE * in ffs_validate()
414 roundup(fsopts->inodes, ffs_opts->bsize / DINODE2_SIZE); in ffs_validate()
419 fsopts->size = in ffs_validate()
420 fsopts->size * (100 + ffs_opts->minfree) / 100; in ffs_validate()
425 if (fsopts->size < fsopts->minsize) /* ensure meets minimum size */ in ffs_validate()
426 fsopts->size = fsopts->minsize; in ffs_validate()
429 fsopts->size = roundup(fsopts->size, ffs_opts->bsize); in ffs_validate()
432 if (fsopts->roundup > 0) in ffs_validate()
433 fsopts->size = roundup(fsopts->size, fsopts->roundup); in ffs_validate()
437 ffs_opts->density = fsopts->size / fsopts->inodes + 1; in ffs_validate()
441 ffs_dump_fsinfo(fsopts); in ffs_validate()
443 dir, (long long)fsopts->size, (long long)fsopts->inodes); in ffs_validate()
446 if (fsopts->maxsize > 0 && fsopts->size > fsopts->maxsize) { in ffs_validate()
448 dir, (long long)fsopts->size, (long long)fsopts->maxsize); in ffs_validate()
484 ffs_create_image(const char *image, fsinfo_t *fsopts) in ffs_create_image() argument
497 assert (fsopts != NULL); in ffs_create_image()
500 if (fsopts->offset == 0) in ffs_create_image()
502 if ((fsopts->fd = open(image, oflags, 0666)) == -1) { in ffs_create_image()
509 if (fstatvfs(fsopts->fd, &sfs) == -1) { in ffs_create_image()
518 bufrem = fsopts->size; in ffs_create_image()
519 if (fsopts->sparse) { in ffs_create_image()
520 if (ftruncate(fsopts->fd, bufrem) == -1) { in ffs_create_image()
522 fsopts->sparse = 0; in ffs_create_image()
525 if (fsopts->sparse) { in ffs_create_image()
537 if (fsopts->offset != 0) in ffs_create_image()
538 if (lseek(fsopts->fd, fsopts->offset, SEEK_SET) == -1) { in ffs_create_image()
545 i = write(fsopts->fd, buf, MIN(bufsize, bufrem)); in ffs_create_image()
568 fs = ffs_mkfs(image, fsopts, tstamp); in ffs_create_image()
569 fsopts->superblock = (void *)fs; in ffs_create_image()
573 t = (time_t)((struct fs *)fsopts->superblock)->fs_time; in ffs_create_image()
575 fsopts->superblock, ctime(&t)); in ffs_create_image()
583 if (fs->fs_cstotal.cs_nifree + (off_t)UFS_ROOTINO < fsopts->inodes) { in ffs_create_image()
588 (long long)fsopts->inodes); in ffs_create_image()
591 return (fsopts->fd); in ffs_create_image()
596 ffs_size_dir(fsnode *root, fsinfo_t *fsopts) in ffs_size_dir() argument
601 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_size_dir()
604 assert(fsopts != NULL); in ffs_size_dir()
609 (long long)fsopts->size, (long long)fsopts->inodes); in ffs_size_dir()
627 fsopts->size += roundup((x), ffs_opts->fsize); \ in ffs_size_dir()
630 fsopts->size += ffs_opts->bsize * \ in ffs_size_dir()
636 fsopts->size += roundup((x), ffs_opts->bsize); \ in ffs_size_dir()
653 fsopts->inodes++; in ffs_size_dir()
667 ffs_size_dir(node->child, fsopts); in ffs_size_dir()
673 (long long)fsopts->size, (long long)fsopts->inodes); in ffs_size_dir()
678 fsnode *root, fsinfo_t *fsopts) in ffs_build_dinode1() argument
712 ufs_rw32(cur->inode->st.st_rdev, fsopts->needswap); in ffs_build_dinode1()
726 fsnode *root, fsinfo_t *fsopts) in ffs_build_dinode2() argument
771 ufs_rw64(cur->inode->st.st_rdev, fsopts->needswap); in ffs_build_dinode2()
784 ffs_populate_dir(const char *dir, fsnode *root, fsinfo_t *fsopts) in ffs_populate_dir() argument
791 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_populate_dir()
795 assert(fsopts != NULL); in ffs_populate_dir()
812 cur->inode->ino = fsopts->curinode; in ffs_populate_dir()
813 fsopts->curinode++; in ffs_populate_dir()
816 ffs_make_dirbuf(&dirbuf, cur->name, cur, fsopts->needswap); in ffs_populate_dir()
820 fsopts->needswap); in ffs_populate_dir()
833 ffs_dump_dirbuf(&dirbuf, dir, fsopts->needswap); in ffs_populate_dir()
857 root, fsopts); in ffs_populate_dir()
860 root, fsopts); in ffs_populate_dir()
871 ffs_write_file(&din, cur->inode->ino, membuf, fsopts); in ffs_populate_dir()
874 (cur->contents) ? cur->contents : path, fsopts); in ffs_populate_dir()
877 ffs_write_inode(&din, cur->inode->ino, fsopts); in ffs_populate_dir()
892 if (! ffs_populate_dir(path, cur->child, fsopts)) in ffs_populate_dir()
907 ffs_write_file(union dinode *din, uint32_t ino, void *buf, fsinfo_t *fsopts) in ffs_write_file() argument
915 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_write_file()
916 struct m_vnode vp = { fsopts, NULL }; in ffs_write_file()
920 assert (fsopts != NULL); in ffs_write_file()
928 in.i_fs = (struct fs *)fsopts->superblock; in ffs_write_file()
1009 ffs_write_inode(&in.i_din, in.i_number, fsopts); in ffs_write_file()
1096 ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts) in ffs_write_inode() argument
1108 ffs_opt_t *ffs_opts = fsopts->fs_specific; in ffs_write_inode()
1112 assert (fsopts != NULL); in ffs_write_inode()
1115 fs = (struct fs *)fsopts->superblock; in ffs_write_inode()
1123 fsopts); in ffs_write_inode()
1125 if (!cg_chkmagic_swap(cgp, fsopts->needswap)) in ffs_write_inode()
1128 assert (isclr(cg_inosused_swap(cgp, fsopts->needswap), cgino)); in ffs_write_inode()
1141 setbit(cg_inosused_swap(cgp, fsopts->needswap), cgino); in ffs_write_inode()
1142 ufs_add32(cgp->cg_cs.cs_nifree, -1, fsopts->needswap); in ffs_write_inode()
1146 ufs_add32(cgp->cg_cs.cs_ndir, 1, fsopts->needswap); in ffs_write_inode()
1154 initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap); in ffs_write_inode()
1156 initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) { in ffs_write_inode()
1165 fs->fs_bsize, buf, fsopts); in ffs_write_inode()
1167 cgp->cg_initediblk = ufs_rw32(initediblk, fsopts->needswap); in ffs_write_inode()
1172 fsopts); in ffs_write_inode()
1176 ffs_rdfs(d, fs->fs_bsize, buf, fsopts); in ffs_write_inode()
1177 if (fsopts->needswap) { in ffs_write_inode()
1190 ffs_wtfs(d, fs->fs_bsize, buf, fsopts); in ffs_write_inode()