From owner-freebsd-fs@FreeBSD.ORG Tue Jul 27 14:26:35 2004 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C538816A4CE for ; Tue, 27 Jul 2004 14:26:35 +0000 (GMT) Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3034243D4C for ; Tue, 27 Jul 2004 14:26:35 +0000 (GMT) (envelope-from robert@fledge.watson.org) Received: from fledge.watson.org (localhost [127.0.0.1]) by fledge.watson.org (8.12.11/8.12.11) with ESMTP id i6REPbad002200; Tue, 27 Jul 2004 10:25:38 -0400 (EDT) (envelope-from robert@fledge.watson.org) Received: from localhost (robert@localhost)i6REPQmQ002196; Tue, 27 Jul 2004 10:25:37 -0400 (EDT) (envelope-from robert@fledge.watson.org) Date: Tue, 27 Jul 2004 10:25:26 -0400 (EDT) From: Robert Watson X-Sender: robert@fledge.watson.org To: ravi In-Reply-To: <1090918658.4727.53.camel@ravin> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-fs@freebsd.org Subject: Re: Regarding freeBSD X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Jul 2004 14:26:35 -0000 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