On Mon, Jun 29, 2020 at 04:53:50PM +0200, Paul Ruizendaal wrote:
On 29 Jun 2020, at 16:45, Larry McVoy
<lm(a)mcvoy.com> wrote:
On Mon, Jun 29, 2020 at 11:11:17AM +0200, Paul Ruizendaal wrote:
As several people have observed in this topic,
indeed there appears to be a close relationship between a device switch and a file system
switch.
Yep. If you think in objects, they are both objects with a set of methods.
Pretty much two instances of the same idea.
Phrased that way all OO programs have a close relationship between them. Maybe:
"they are both rather similar objects with a rather similar set of methods"?
They are two different classes, similar, but not the same. It's really
4 classes, vfs, vnode for FS and block/char for devices. This is from
SunOS 4.1.1 that I happened to have an install image sitting around.
Took me forever to find the device definitions, I resorted to
find . -type f -name '*.h' -print | xargs grep strategy
It's in include/sys/conf.h because, well, that's obvious, right?
struct vfsops {
int (*vfs_mount)(); /* mount file system */
int (*vfs_unmount)(); /* unmount file system */
int (*vfs_root)(); /* get root vnode */
int (*vfs_statfs)(); /* get fs statistics */
int (*vfs_sync)(); /* flush fs buffers */
int (*vfs_vget)(); /* get vnode from fid */
int (*vfs_mountroot)(); /* mount the root filesystem */
int (*vfs_swapvp)(); /* return vnode for swap */
};
struct vnodeops {
int (*vn_open)();
int (*vn_close)();
int (*vn_rdwr)();
int (*vn_ioctl)();
int (*vn_select)();
int (*vn_getattr)();
int (*vn_setattr)();
int (*vn_access)();
int (*vn_lookup)();
int (*vn_create)();
int (*vn_remove)();
int (*vn_link)();
int (*vn_rename)();
int (*vn_mkdir)();
int (*vn_rmdir)();
int (*vn_readdir)();
int (*vn_symlink)();
int (*vn_readlink)();
int (*vn_fsync)();
int (*vn_inactive)();
int (*vn_lockctl)();
int (*vn_fid)();
int (*vn_getpage)();
int (*vn_putpage)();
int (*vn_map)();
int (*vn_dump)();
int (*vn_cmp)();
int (*vn_realvp)();
int (*vn_cntl)();
};
/* two different device classes, block and char */
struct bdevsw {
int (*d_open)();
int (*d_close)();
int (*d_strategy)();
int (*d_dump)();
int (*d_psize)();
int d_flags;
};
struct cdevsw {
int (*d_open)();
int (*d_close)();
int (*d_read)();
int (*d_write)();
int (*d_ioctl)();
int (*d_reset)();
int (*d_select)();
int (*d_mmap)();
struct streamtab *d_str;
int (*d_segmap)();
};
--
---
Larry McVoy lm at
mcvoy.com http://www.mcvoy.com/lm