102 static mntopts_t ctfs_mntopts = {
103 0,
104 NULL
105 };
106
107 static vfsdef_t vfw = {
108 VFSDEF_VERSION,
109 "ctfs",
110 ctfs_init,
111 VSW_HASPROTO|VSW_ZMOUNT,
112 &ctfs_mntopts,
113 };
114
115 extern struct mod_ops mod_fsops;
116
117 static struct modlfs modlfs = {
118 &mod_fsops, "contract filesystem", &vfw
119 };
120
121 static struct modlinkage modlinkage = {
122 MODREV_1, (void *)&modlfs, NULL
123 };
124
125 int
126 _init(void)
127 {
128 return (mod_install(&modlinkage));
129 }
130
131 int
132 _info(struct modinfo *modinfop)
133 {
134 return (mod_info(&modlinkage, modinfop));
135 }
136
137 int
138 _fini(void)
139 {
140 /*
141 * As unloading filesystem modules isn't completely safe, we
142 * don't allow it.
348 for (i = 0, total = 0; i < ct_ntypes; i++)
349 total += contract_type_count(ct_types[i]);
350 sp->f_files = total;
351 sp->f_favail = sp->f_ffree = INT_MAX - total;
352 (void) cmpldev(&d32, vfsp->vfs_dev);
353 sp->f_fsid = d32;
354 (void) strlcpy(sp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name,
355 sizeof (sp->f_basetype));
356 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
357 sp->f_namemax = CTFS_NAME_MAX;
358 (void) strlcpy(sp->f_fstr, "contract", sizeof (sp->f_fstr));
359
360 return (0);
361 }
362
363 static const fs_operation_def_t ctfs_vfstops[] = {
364 { VFSNAME_MOUNT, { .vfs_mount = ctfs_mount } },
365 { VFSNAME_UNMOUNT, { .vfs_unmount = ctfs_unmount } },
366 { VFSNAME_ROOT, { .vfs_root = ctfs_root } },
367 { VFSNAME_STATVFS, { .vfs_statvfs = ctfs_statvfs } },
368 { NULL, NULL }
369 };
370
371 /*
372 * ctfs_common_getattr
373 *
374 * Implements functionality common to all ctfs VOP_GETATTR entry
375 * points. It assumes vap->va_size is set.
376 */
377 void
378 ctfs_common_getattr(vnode_t *vp, vattr_t *vap)
379 {
380 vap->va_uid = 0;
381 vap->va_gid = 0;
382 vap->va_rdev = 0;
383 vap->va_blksize = DEV_BSIZE;
384 vap->va_nblocks = howmany(vap->va_size, vap->va_blksize);
385 vap->va_seq = 0;
386 vap->va_fsid = vp->v_vfsp->vfs_dev;
387 vap->va_nodeid = gfs_file_inode(vp);
388 }
500 return (0);
501 }
502
503 /* ARGSUSED */
504 static ino64_t
505 ctfs_root_do_inode(vnode_t *vp, int index)
506 {
507 return (CTFS_INO_TYPE_DIR(index));
508 }
509
510 static const fs_operation_def_t ctfs_tops_root[] = {
511 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
512 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
513 { VOPNAME_IOCTL, { .error = fs_inval } },
514 { VOPNAME_GETATTR, { .vop_getattr = ctfs_root_getattr } },
515 { VOPNAME_ACCESS, { .vop_access = ctfs_access_dir } },
516 { VOPNAME_READDIR, { .vop_readdir = gfs_vop_readdir } },
517 { VOPNAME_LOOKUP, { .vop_lookup = gfs_vop_lookup } },
518 { VOPNAME_SEEK, { .vop_seek = fs_seek } },
519 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
520 { NULL, NULL }
521 };
|
102 static mntopts_t ctfs_mntopts = {
103 0,
104 NULL
105 };
106
107 static vfsdef_t vfw = {
108 VFSDEF_VERSION,
109 "ctfs",
110 ctfs_init,
111 VSW_HASPROTO|VSW_ZMOUNT,
112 &ctfs_mntopts,
113 };
114
115 extern struct mod_ops mod_fsops;
116
117 static struct modlfs modlfs = {
118 &mod_fsops, "contract filesystem", &vfw
119 };
120
121 static struct modlinkage modlinkage = {
122 MODREV_1, { (void *)&modlfs, NULL }
123 };
124
125 int
126 _init(void)
127 {
128 return (mod_install(&modlinkage));
129 }
130
131 int
132 _info(struct modinfo *modinfop)
133 {
134 return (mod_info(&modlinkage, modinfop));
135 }
136
137 int
138 _fini(void)
139 {
140 /*
141 * As unloading filesystem modules isn't completely safe, we
142 * don't allow it.
348 for (i = 0, total = 0; i < ct_ntypes; i++)
349 total += contract_type_count(ct_types[i]);
350 sp->f_files = total;
351 sp->f_favail = sp->f_ffree = INT_MAX - total;
352 (void) cmpldev(&d32, vfsp->vfs_dev);
353 sp->f_fsid = d32;
354 (void) strlcpy(sp->f_basetype, vfssw[vfsp->vfs_fstype].vsw_name,
355 sizeof (sp->f_basetype));
356 sp->f_flag = vf_to_stf(vfsp->vfs_flag);
357 sp->f_namemax = CTFS_NAME_MAX;
358 (void) strlcpy(sp->f_fstr, "contract", sizeof (sp->f_fstr));
359
360 return (0);
361 }
362
363 static const fs_operation_def_t ctfs_vfstops[] = {
364 { VFSNAME_MOUNT, { .vfs_mount = ctfs_mount } },
365 { VFSNAME_UNMOUNT, { .vfs_unmount = ctfs_unmount } },
366 { VFSNAME_ROOT, { .vfs_root = ctfs_root } },
367 { VFSNAME_STATVFS, { .vfs_statvfs = ctfs_statvfs } },
368 { NULL, { NULL } }
369 };
370
371 /*
372 * ctfs_common_getattr
373 *
374 * Implements functionality common to all ctfs VOP_GETATTR entry
375 * points. It assumes vap->va_size is set.
376 */
377 void
378 ctfs_common_getattr(vnode_t *vp, vattr_t *vap)
379 {
380 vap->va_uid = 0;
381 vap->va_gid = 0;
382 vap->va_rdev = 0;
383 vap->va_blksize = DEV_BSIZE;
384 vap->va_nblocks = howmany(vap->va_size, vap->va_blksize);
385 vap->va_seq = 0;
386 vap->va_fsid = vp->v_vfsp->vfs_dev;
387 vap->va_nodeid = gfs_file_inode(vp);
388 }
500 return (0);
501 }
502
503 /* ARGSUSED */
504 static ino64_t
505 ctfs_root_do_inode(vnode_t *vp, int index)
506 {
507 return (CTFS_INO_TYPE_DIR(index));
508 }
509
510 static const fs_operation_def_t ctfs_tops_root[] = {
511 { VOPNAME_OPEN, { .vop_open = ctfs_open } },
512 { VOPNAME_CLOSE, { .vop_close = ctfs_close } },
513 { VOPNAME_IOCTL, { .error = fs_inval } },
514 { VOPNAME_GETATTR, { .vop_getattr = ctfs_root_getattr } },
515 { VOPNAME_ACCESS, { .vop_access = ctfs_access_dir } },
516 { VOPNAME_READDIR, { .vop_readdir = gfs_vop_readdir } },
517 { VOPNAME_LOOKUP, { .vop_lookup = gfs_vop_lookup } },
518 { VOPNAME_SEEK, { .vop_seek = fs_seek } },
519 { VOPNAME_INACTIVE, { .vop_inactive = gfs_vop_inactive } },
520 { NULL, { NULL } }
521 };
|