Date: Tue, 27 Jul 2004 10:25:26 -0400 (EDT) From: Robert Watson <rwatson@freebsd.org> To: ravi <ravi.nanjundappa@ap.sony.com> Cc: freebsd-fs@freebsd.org Subject: Re: Regarding freeBSD Message-ID: <Pine.NEB.3.96L.1040727101114.89115G-100000@fledge.watson.org> In-Reply-To: <1090918658.4727.53.camel@ravin>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 27 Jul 2004, ravi wrote: > I wanted to know whether there is any structure in FreeBSD that > corresponds to the file_operations structure of Linux ? In FreeBSD, the equivilent of 'struct inode' is 'struct vnode'. The inode operation fector on Linux, 'struct file_operations' is equivilent to the 'v_op' vnode operation vector in FreeBSD. Most file systems use just a couple of operation vectors -- one for regular files/directories, another for fifos, and another for special devices. The file systems will provide their own vector and then overlay shared vectors from file system libraries to implement fifos and special devices -- fs/fifofs and fs/specfs respectively. In Linux, inode vectors are more frequently substituted for special nodes, whereas in FreeBSD, file systems that provide for special nodes often expose an abstraction to the services creating said nodes. I.e., in Linux, a broad range of devices override the file operation vector for device nodes. In FreeBSD, devfs implements the vnode operation vectors and forwards specific requests via the device's 'struct devsw' -- open, close, read, write, ioctl, poll, etc. As such, it's fairly unusual to directly override vnode operation vectors; rather, special case nodes attach to various service APIs to offer method implementations (i.e., fill out a cdevsw and attach it using make_dev()). > Is there any way to register read and write functions in a kernel module > for procfs ? I think it might be helpful to know what it is you're currently up to -- are you building a new file system based on pseudofs, extending procfs or linprocfs to add new entries, or building an entirely new file system? Are you adding new per-process procfs entries? The advice you get will depend a bit on what it is you want to accomplish... If you intend to modify the FreeBSD procfs to add new per-process controls, take a look at fs/procfs/procfs_init(), which registers the per-process entries with pseudofs, including their procfs_do*() methods. In particular, I'd probably look at procfs_doprocctl() in proc_ctl.c, which implements the write functionality for /proc/*/ctl, and procfs_doprocmap(), which implements the read functionality for /proc/*/map. Robert N M Watson FreeBSD Core Team, TrustedBSD Projects robert@fledge.watson.org Principal Research Scientist, McAfee Research
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.NEB.3.96L.1040727101114.89115G-100000>