ravi.nanjundappa at ap.sony.com
Tue Jul 20 21:36:40 PDT 2004
I'm able to create a proc file under /proc directory using
pfs_create_file() with the read and write permission in a kernel module
. But I don't know how to read and write to /proc/file .
Can u please tell me how to do it ?
On Wed, 2004-07-21 at 08:19, Robert Watson wrote:
> On Mon, 19 Jul 2004, ravi wrote:
> > Hi,
> > 1) Can u explain me the usage of different arguments to
> > () function ?
> Again, details a bit hazy to me here, but roughly speaking:
> 'parent' is the parent directory where the object will appear
> 'name' is the name it will have
> 'fill' is the function pointer provided by the pseudofs-derived file
> system to implement the node. I.e., procfs_doproccmdline.
> 'attr' appears to be a function pointer allowing the pseudo file
> to modify the set of attributes returned for a node; this is used by
> procfs to modify the set of permissions returns for certain objects
> (looks like the debugging entries in per-process directories).
> 'vis' is a visibility test function: should the node be visible to a
> particular caller (i.e., "you can't see that process for security
> 'flags' is a set of node flags, such as PFS_RD, PFS_WR, etc, as found
> I'd suggest working from examples in src/sys/fs/procfs/procfs.c;
> is largely an abstraction layer to let the bulk of the file system logic
> be shared between procfs and linprocfs, since they're similar (but
> > 2) what is the use of PFS_PROCDEP in the following statement ?
> > dir = pfs_create_dir(root, "pid",
> > procfs_attr, NULL, PFS_PROCDEP);
> As I mentioned in a previous e-mail, it's creating a template
> directory that will be expanded into many perceived directories on
> one per process. If you look at procfs_init(), you'll see that it
> the template, then places a bunch of nodes in the template that will be
> valid for each process.
> > 3) there is no entry under /proc with the name "pid" . Why is it so ?
> See previous e-mail -- the template has its name replaced with each
> possible pid, and 'pid' is a place-holder.
> > 4) And even though for some of the proc entries the permission given
> > PFS_RDWR , the file is getting created with the read permission only .
> > What is the reason for this ?
> pfs_getattr() appears to always return read-only entries, except where
> pn_attr() is implemented on the node. The actual protections appear to
> calculated in several places -- for example, pfs_visible() uses various
> visibility tests, including per-process tests, etc. The permission bits
> are probably not a perfect guide to access rights.
> Robert N M Watson FreeBSD Core Team, TrustedBSD Projects
> robert at fledge.watson.org Principal Research Scientist, McAfee
More information about the freebsd-fs