Re: How to block write access to a file.
Re: How to block write access to a file.
- Subject: Re: How to block write access to a file.
- From: Marek Kozubal <email@hidden>
- Date: Tue, 25 Feb 2003 19:19:40 -0500 (EST)
On Tue, 25 Feb 2003, Mr. Wong wrote:
>
Can someone give me some pointers on this? What should I be using? Has
>
anyone done this before? I am aware that there will be inconsistancies and
>
errors introduced but I'm willing to tolerate / fix / learn about the issues
>
involved.
There is a way to do this. What you want to do is get the source for the
nullfs filesystem and modify it to cover the mount vnode instead of
mapping a vnode from another part of the file system.
Then *all* file system accesses go though your layer before hitting the
underlying HFS or whatever file system. You can add code to VOP_WRITE,
VOP_ACCESS, VOP_RMDIR, VOP_CREATE, etc to prevent writing to the
underlying file system. nullfs already does this if the mount flags say
the nullfs mount layer is a read-only file system.
You should read up about the VFS stack and stacked file systems to
undertsand whats going on. Also look at the nullfs code. If you're
serious about doing this, I would highly recommend you setup a 2 computer
Kernel debug setup as well so you can figure out the ref-count and locking
kernel panics you'll probably see during development.
I've also been using the URL
http://www.gsp.com/support/man/ which has man
page entries for the various VOP/VFS functions, even though its FreeBSD
oriented the ideas still work. Also the file vnode_if.src in the open
source tree (in xnu i think) is very helpful in the locking protocols.
All of this is of course not offically supported by Apple as they are not
promising not to break this in a future release.
---
Marek Kozubal
email@hidden
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.